View unanswered posts | View active topics It is currently Fri Sep 19, 2014 3:53 pm






Reply to topic  [ 2 posts ] 
RobotC 3.50 bug 2 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post RobotC 3.50 bug 2
I found bug #2.
Code:
task main()
{
    short x = 55;
   
    nxtDisplayTextLine(0, "x0=%d", x);
    nxtDisplayTextLine(1, "x1=%d", ((long)x + 128)*200);
    nxtDisplayTextLine(2, "x2=%d", ((long)x + 128)*200/255);
    nxtDisplayTextLine(3, "x3=%d", (((long)x + 128)*200)/255);
}

It gave the following output:
Quote:
x0=55
x1=36600
x2=0
x3=143

Admittedly, I may be at fault here. I believe ANSI-C evaluates operators with the same precedence from left to right. So it is supposed to multiply before divide. But I always tell the students to be safe and add parenthesis to make sure. And I broke my own advice. Regardless, I do think it is an ANSI-C compliance bug, although I can work around it with the extra pair of parenthesis.


Sat Sep 15, 2012 3:17 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: RobotC 3.50 bug 2
Fixed for next release.


Mon Sep 17, 2012 2:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.