? : syntax

Blitz3D Forums/Blitz3D Beginners Area/? : syntax

i can't remember and can't find anywhere how to use this syntax:

e\rotyspeed# = (Rand(0,1) = 1) ? -3:3

I'm looking for rand to return 0 or 1, and i translate that into -3 or 3

clues for the clueless?

As far as I'm aware it doesn't exist in blitz however...
x = ((Rand(0,1) * 2) - 1) * 3

explained...
(0 or 1) * 2 = (0 or 2) - 1 = (-1 or 1) * 3 = (-3 or 3)

That said... I'm not sure if it's going to be faster to just do
if rand(0,1) then x=3 else x=-3

There is no ternary operator in B3d; that said, there's no reason why you can't create your own function to accomplish the same thing.

ugh

could have sworn it had it.

thanks guys

e\rotyspeed# = 6*Rand(0,1) - 3

@Floyd's solution is good.

Unrelated to the actual question asked but it will work, yes.

I'm looking for rand to return 0 or 1, and i translate that into -3 or 3

@WarrenM: How is it unrelated to the original question (quoted above)? Floyd's solution answers the question precisely and well-done, at that.