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

what :
code: [select]
long = 1000l*255l;
give?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Disturbing math problem with Arduino. Overflow?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums