Disturbing math problem with Arduino. Overflow?
hi!
i've stumbled upon problem cant figure out cause of.
this little code snippet test program pretty sums i'm having hard time figuring out:
long b = 255000;
serial.println(b);
long = 1000*255; // 1000 * 255 = 255000 //
serial.println(a);
delay(1000);
the serial output of 'b' is: 255000
while serial output 'a' is: -7144
could please explain me why happens?
i first stumbled upon when tried use map function. when returned '0' started looking , above couldn't further on own.
thanks!
-rindis
i've stumbled upon problem cant figure out cause of.
this little code snippet test program pretty sums i'm having hard time figuring out:
long b = 255000;
serial.println(b);
long = 1000*255; // 1000 * 255 = 255000 //
serial.println(a);
delay(1000);
the serial output of 'b' is: 255000
while serial output 'a' is: -7144
could please explain me why happens?
i first stumbled upon when tried use map function. when returned '0' started looking , above couldn't further on own.
thanks!
-rindis
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Disturbing math problem with Arduino. Overflow?
arduino
Comments
Post a Comment