# Data type: very high integer

**URL:** https://discourse.processing.org/t/data-type-very-high-integer/44680
**Category:** Beginners
**Created:** [July 2, 2024, 8:44am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680 "2024-07-02T08:44:08Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 2, 2024, 8:44am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/1 "2024-07-02T08:44:08Z")

</div>

simple question:

we just try to calculate the length of a lightyear.

using int a = 300000 \* // m/s — error ---- km/s  
60\*60 \* // to km/h  
24 \* // day  
365; // year  
But rounding error occurs

Unclear why

(I understand int is only up to 32000)

So I’d like to ask: which data type I need to use, long, double or Integer?

I need longInt in theory, what is this called?

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [July 2, 2024, 9:31am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/3 "2024-07-02T09:31:25Z")

</div>

An int can store integers approximately +/-2000000000 so a long data type might be suitable but if you want fractional values the double data type gives 15/16 significant digits

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 2, 2024, 9:38am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/4 "2024-07-02T09:38:16Z")

</div>

No fractionally needed

But using text() command I receive a rounding error before the . dot (!)

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 2, 2024, 9:40am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/5 "2024-07-02T09:40:02Z")

</div>

> [@quark](#):
>
> approximately +/-2000000000

The result is 9 trillion kilometers so this could be the  
issue

Do we have a longer integer data type

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [July 2, 2024, 9:51am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/6 "2024-07-02T09:51:50Z")

</div>

Shouldn’t be a dot with an integer value probably due to some data type conversion by Processing

Use long instead of int for bigger values

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [July 2, 2024, 9:54am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/7 "2024-07-02T09:54:09Z")

</div>

If you use long then I suggest you use native Java to convert to a string before passing to text

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [July 2, 2024, 10:43am UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/8 "2024-07-02T10:43:13Z")

</div>

Hello,

I have run into this issue before.  
Units for speed of light corrected.  
I changed everything to meters.  
Don’t forget the L.

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/8/e89088d1e2d85eecfdc0dd3044090411bcf0f5c5.png)

References:

- [Speed of light - Wikipedia](https://en.wikipedia.org/wiki/Speed_of_light)
- [Advanced Java/Declaring float and long Literals - Wikiversity](https://en.wikiversity.org/wiki/Advanced_Java/Declaring_float_and_long_Literals)
- [Primitive Data Types (The Java™ Tutorials \> Learning the Java Language \> Language Basics)](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html)
- [Java Data Types](https://www.w3schools.com/java/java_data_types.asp)

`:)`

---

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 3, 2024, 3:08pm UTC](https://discourse.processing.org/t/data-type-very-high-integer/44680/9 "2024-07-03T15:08:15Z")

</div>

Thanks.

The reason for the error was the internal conversion  
to String performed by the text() command.

When you convert the value as shown (or convent before the  
text() command and bring the result in a new String var)  
and use text() then, you are good.
