# Converting from int to long

**URL:** https://discourse.processing.org/t/converting-from-int-to-long/38923
**Category:** Beginners
**Created:** [September 21, 2022, 6:37pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923 "2022-09-21T18:37:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![REK166](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@REK166](https://discourse.processing.org/u/REK166)
#### Post date: [September 21, 2022, 6:37pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923/1 "2022-09-21T18:37:06Z")

</div>

how can i convert an int type into a long type value?

---

<div class="post-metadata">

### Author: ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)
#### Post date: [September 21, 2022, 6:37pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923/2 "2022-09-21T18:37:56Z")

</div>

Take a look at this code:

```auto
int yourInt=5;
long yourLong=(long) yourInt;
println(yourLong);

```

You can generally convert all number types into each other that way.  
I hope this helps!

---

<div class="post-metadata">

### Author: ![REK166](https://avatars.discourse-cdn.com/v4/letter/r/c57346/32.png) [@REK166](https://discourse.processing.org/u/REK166)
#### Post date: [September 21, 2022, 6:44pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923/3 "2022-09-21T18:44:32Z")

</div>

thanks a lot, that did in fact work. 😀

---

<div class="post-metadata">

### Author: ![NumericPrime](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/numericprime/32/16318_2.png) [@NumericPrime](https://discourse.processing.org/u/NumericPrime)
#### Post date: [September 21, 2022, 6:46pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923/4 "2022-09-21T18:46:57Z")

</div>

No problem! A thing to keep in mind is that when converting from a float/double to a int/long all digits after the comma will be cut!

---

<div class="post-metadata">

### Author: ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)
#### Post date: [September 21, 2022, 7:17pm UTC](https://discourse.processing.org/t/converting-from-int-to-long/38923/5 "2022-09-21T19:17:53Z")

</div>

> [@REK166](#):
>
> How can I convert an `int` type into a `long` type value?

Java automatically upgrades an integer value to `long` type by simpling assigning it to a `long` variable:

```auto
int myInt = 10;
long myLong = myInt;

println(myInt, myLong); // 10, 10
exit();

```

However, when using literals that exceed `2 ^ 31` we have to suffix them w/ `L` or `l`:

```auto
//long wrongLong = 4_000_000_000;
long correctLong = 4_000_000_000L;

println(correctLong); // 4000000000
exit();

```
