|RobotC 8.23 firmware fails with unsigned values
|Page 1 of 1|
|Author:||tarribas [ Tue Jan 29, 2013 12:36 pm ]|
|Post subject:||RobotC 8.23 firmware fails with unsigned values|
I have a problem with the unsigned values that in previouse version works well:
This code shows in the NXT window: 1680147487
and with this code:
nxtDisplayTextLine(1, "%i",(unsigned int)a);
The result is: -1
|Author:||tfriez [ Wed Jan 30, 2013 10:23 am ]|
|Post subject:||Re: RobotC 8.23 firmware fails with unsigned values|
The compiler is calculating this correctly. a "byte" is the same as a "char" which has a range of -128 to +127. When you assign a value of 255, it will overflow and end up with a value of -1.
Here is proof from a GCC compiler which exhibits the same behavior. http://i.imgur.com/BQQ7yQZ.png
Try using a ubyte instead which has a range of 0-255 and will be able to store your value.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group