iccaros Posted October 20, 2006 Report Share Posted October 20, 2006 while (X<0)x += sTwoPI;)I have never seen += or the opisite -=thanks Quote Link to post Share on other sites
shanenin Posted October 20, 2006 Report Share Posted October 20, 2006 (edited) it appears to be a counter. it will keep looping until the value of x is less then 0I think these are equivailant(forgot my syntax, I don't know any java)x += sTwoPIx = x + sTwoPII will use python for an example. Lets say you want somthing to loop 5 times, each time it will print the value of "x". Once the value of x hits 5 it will stopx = 0while x < 5: x = x + 1 print xthis is the same thing using the other syntaxx = 0while x < 5: x += 1 print xMy programming skills are so forgotten, I had to look up the syntax to do this. Edited October 20, 2006 by shanenin Quote Link to post Share on other sites
iccaros Posted October 20, 2006 Author Report Share Posted October 20, 2006 so your saying its the same as doing a x++? Quote Link to post Share on other sites
shanenin Posted October 20, 2006 Report Share Posted October 20, 2006 to be honest, I have never seen that syntax. Is that java? Quote Link to post Share on other sites
jcl Posted October 21, 2006 Report Share Posted October 21, 2006 (edited) shanenin is correct. Those are compound assignment operators. x op= y is equivalent to x = x op y (except that x is evaluated once instead twice). Edited October 21, 2006 by jcl Quote Link to post Share on other sites
iccaros Posted October 21, 2006 Author Report Share Posted October 21, 2006 to be honest, I have never seen that syntax. Is that java? c++ java, c# and VB and C X++ would incrament X by one , its the same as X = X + 1X-- is the opisite Quote Link to post Share on other sites
shanenin Posted October 21, 2006 Report Share Posted October 21, 2006 cool :-) Quote Link to post Share on other sites
iccaros Posted October 21, 2006 Author Report Share Posted October 21, 2006 so since my entier class is as suchpublic static double fixAzimuth_02PI (double x)while (x < 0){ x += sTwoPI;}while (x > sTwoPI){ x -= sTwoPi;}return x;}private static final double sTwoPi = 2.0 * Math.PI;so I gather this is keeping x between 0 and 2*PI Quote Link to post Share on other sites
jcl Posted October 21, 2006 Report Share Posted October 21, 2006 (edited) X++ would incrament X by one , its the same as X = X + 1Not quite the same. x = x + 1 increments x and returns the new value, whereas x++ increments x and returns the previous value.so I gather this is keeping x between 0 and 2*PILooks like but I'm not sure it's correct. Seem like the angle θ should be normalized to 0 <= θ < 2π rather than 0 < θ <= 2π. Edited October 21, 2006 by jcl Quote Link to post Share on other sites
iccaros Posted October 21, 2006 Author Report Share Posted October 21, 2006 you are correct, ++x would incrament and send incramented while X++ incarments and sends prior but x is still incramented. so its the same as ++x Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.