View unanswered posts | View active topics It is currently Wed Aug 27, 2014 1:56 pm






Reply to topic  [ 5 posts ] 
Problem with *= operator 
Author Message
Rookie

Joined: Sun Feb 27, 2011 4:42 pm
Posts: 2
Post Problem with *= operator
For some reason, I cannot get the *= operator to work in RobotC 2.30 or 2.31 for Cortex.

For example, if I write something like this:

int bob = 2;
bob *= 2;

or bob = bob*2;

The value of bob, becomes 0 instead of the expected 4.


Sun Feb 27, 2011 4:47 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Problem with *= operator
I just tested this with ROBOTC for NXT and Cortex and it works fine:

Code:
task main () {
   int bob = 2;
   bob *= 2;
   while(true);
}


Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Feb 27, 2011 6:27 pm
Profile WWW
Rookie

Joined: Sun Feb 27, 2011 4:42 pm
Posts: 2
Post Re: Problem with *= operator
mightor wrote:
I just tested this with ROBOTC for NXT and Cortex and it works fine:

Code:
task main () {
   int bob = 2;
   bob *= 2;
   while(true);
}


Regards,
Xander


Well, I tried it again and I still couldn't get it to work.

However, if I do something like this:

int bob = 2;
int bobette = bob * 2;
bob = bobette;

Then in this case bob is equal to 4.

Do you have any idea why this might be the case?


Sun Feb 27, 2011 8:58 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post Re: Problem with *= operator
Post your entire program, so I can do this with yours.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Feb 28, 2011 2:39 am
Profile WWW
Rookie

Joined: Wed Feb 09, 2011 1:08 am
Posts: 27
Post Re: Problem with *= operator
I just tested this and found it works fine. There is a case if you overflow the int it goes to zero which would stay zero as zero * anything = 0

cheers Kb


Sat Jul 02, 2011 12:15 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.