Maths Expression
Blitz3D Forums/Blitz3D Beginners Area/Maths Expression
| ||
Help !. Whats the maths expression you can use to flip a variable between 0 and 1 everytime you call it ? I've forgotten. |
| ||
x = 1 - x or x = Not x In general, to flip between values a and b use the sum s s = a + b Now to flip x x = s - x ; if x was one of a or b it is now the other. |
| ||
Thats the one, thanks Floyd Just out of interest, I wonder which one would compile to the faster instruction ?? |
| ||
or x=x Xor 1 |
| ||
Another useful value flipping trick is:- x = -x to flip the positive/negative sign of x. Not what you were after but it might come in handy for you sometime. |