ROBOTC.net forumshttp://robotc.net/forums/ Problem with *= operatorhttp://robotc.net/forums/viewtopic.php?f=11&t=3072 Page 1 of 1

 Author: bobjam [ Sun Feb 27, 2011 4:47 pm ] Post subject: 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.

Author:  mightor [ Sun Feb 27, 2011 6:27 pm ]
Post subject:  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

Author:  bobjam [ Sun Feb 27, 2011 8:58 pm ]
Post subject:  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?

 Author: mightor [ Mon Feb 28, 2011 2:39 am ] Post subject: Re: Problem with *= operator Post your entire program, so I can do this with yours.- Xander

 Author: fretless_kb [ Sat Jul 02, 2011 12:15 pm ] Post subject: 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 = 0cheers Kb

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