# Did I find a bug?

**URL:** <https://discourse.processing.org/t/did-i-find-a-bug/42645>\
**Category:** Beginners\
**Created:** [August 23, 2023, 7:22pm UTC](https://discourse.processing.org/t/did-i-find-a-bug/42645 "2023-08-23T19:22:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrinalino](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adrinalino](https://discourse.processing.org/u/adrinalino)\
**Post date:** [August 23, 2023, 7:22pm UTC](https://discourse.processing.org/t/did-i-find-a-bug/42645/1 "2023-08-23T19:22:38Z")

</div>

I was trying to work my way around the maximum size of an array (2147483647) when I came across this anomaly :

```auto
void setup() {
  long i = 999_999_967L;
  println(int(i));
}

```

results in : 1000000000  
The value of the long is incorrectly converted without throwing an error.

It turns out that this starts happening at 16777217.  
Is this a bug or just a restriction that is not documented.  
Cheers,  
Adriaan.

---

<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:** [August 23, 2023, 7:35pm UTC](https://discourse.processing.org/t/did-i-find-a-bug/42645/2 "2023-08-23T19:35:37Z")

</div>

> **[int / Reference](https://processing.org/reference/int.html)**
>
> Datatype for integers, numbers without a decimal point. Integers can be as large as 2,147,483,647 and as low as -2,147,483,648. They are stored as 32 bits of information. The first time a variable is …

> **[Primitive Data Types (The Java™ Tutorials \>        
            Learning...](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)**
>
> This beginner Java tutorial describes fundamentals of programming in the Java programming language

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [August 23, 2023, 7:44pm UTC](https://discourse.processing.org/t/did-i-find-a-bug/42645/3 "2023-08-23T19:44:05Z")

</div>

Hi

> **[long / Reference](https://processing.org/reference/long.html)**
>
> Datatype for large integers. While integers can be as large as 2,147,483,647 and as low as -2,147,483,648 (stored as 32 bits), a long integer has a minimum value of -9,223,372,036,854,775,808 a…

---

<div class="post-metadata">

**Author:** ![adrinalino](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@adrinalino](https://discourse.processing.org/u/adrinalino)\
**Post date:** [August 23, 2023, 9:46pm UTC](https://discourse.processing.org/t/did-i-find-a-bug/42645/4 "2023-08-23T21:46:45Z")

</div>

From the referents page:  
int() : Converts any value of a primitive data type ( **boolean** , **byte** , **char** , **color** , **float** , **int** , or **long** ) or String to its integer representation.

This does work but for a long this stops at 16777217.

At a a different place it says :  
you’ll usually have to convert to a **int** using the **(int)** syntax.

This works for all values.  
Thanks for your help.  
Cheers,  
Adriaan.
