ROBOTC.net forums
http://www.robotc.net/forums/

a compiler bug.
http://www.robotc.net/forums/viewtopic.php?f=63&t=5031
Page 1 of 1

Author:  Guoxy [ Thu Oct 25, 2012 10:25 am ]
Post subject:  a compiler bug.

RobotC 3.51

v1 = -1.0 * sin(30.0/180.0*PI-90/180.0*PI)* 0 -(cos(30.0/180.0*PI-90/180.0*PI) * 0) + 0.135*90/180.0*PI;
v2 = -1.0 * sin(30.0/180.0*PI-90/180.0*PI)* 0 - cos(30.0/180.0*PI-90/180.0*PI) * 0 + 0.135*90/180.0*PI;

The two expressions above should get the same result, but it did not.

the result is :v1=0.212(correct) v2=-0.212(wrong)

Author:  MHTS [ Thu Oct 25, 2012 5:30 pm ]
Post subject:  Re: a compiler bug.

I don't have time to confirm it but it looks like it may be the same bug as:
viewtopic.php?f=63&t=4839
which is already fixed in the beta build.

Author:  Guoxy [ Fri Oct 26, 2012 3:06 am ]
Post subject:  Re: a compiler bug.

MHTS wrote:
I don't have time to confirm it but it looks like it may be the same bug as:
viewtopic.php?f=63&t=4839
which is already fixed in the beta build.



Thank you for the response.

I think it's the same bug. Found in 3.50, but still exists in 3.51

Author:  Spiked3 [ Fri Oct 26, 2012 2:34 pm ]
Post subject:  Re: a compiler bug.

I am running 3.5.4_1

Code:
 delta = degrees  * pi.ticksForFullPilotTurn / 360.0;
 printf("math %d * %d / 360 = %d", degrees, pi.ticksForFullPilotTurn, delta);


produces
math -91 * 522 / 360 = 50

should be -131ish.

edit; actually I can't get any math to work at the moment :(
Code:
 int temp = degrees * pi.ticksForFullPilotTurn;
 delta = temp / 360;


math -76 * 522 / 360 = 71 should be -110ish - it is beyond a paren / order of operations thing.

Author:  tfriez [ Mon Nov 19, 2012 4:26 pm ]
Post subject:  Re: a compiler bug.

This has been resolved for 3.54 - It was a matter of float/long calculations being truncated to 16 bits and causing really wacky numbers.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/