Hi All,
I have a few questions about working with long numbers in processing and wondered if anyone could clarify for me?
I ran the following code to start with:
I have a few questions about working with long numbers in processing and wondered if anyone could clarify for me?
I ran the following code to start with:
void setup()
{
size(800, 100);
background(0);
}
void draw()
{
int bigInt = 987654321 * 123456789;
println("the value of the integer bigInt is "+bigInt);
delay(1000);
PFont font;
font = loadFont("ArialMT-20.vlw");
textFont(font, 20);
String s =(""+bigInt);
text(s, width/2, height/2);
long bigLong = 987654321 * 123456789;
println("the value of the long bigLong is "+bigLong);
}
For each the console prints: -67153019 and the same appears in the window. Surely the answer is: 121932631112635260. Can anyone tell me what's going on?
I started playing with printing out number values as I want to print a large changing calculated number out to the display window and I wanted to check if processing would truncate it. The above reading has confused me on route to my original task. Any clues welcome! I'm guessing this is some form of trunctuation, but I don't understand it.
I started playing with printing out number values as I want to print a large changing calculated number out to the display window and I wanted to check if processing would truncate it. The above reading has confused me on route to my original task. Any clues welcome! I'm guessing this is some form of trunctuation, but I don't understand it.
1