The Rand(0,2) - 1 trick is good enough for this particular problem.
The trouble is that Rand() should round down, i.e. toward -Infinity.
It actually rounds toward zero, which is how BlitzMax converts floating point values to integer.
Here is an alternate version of Rand() which uses Floor() to enforce the correct rounding.
I haven't seriously tested this, but it seems like it should work.
The trouble is that Rand() should round down, i.e. toward -Infinity.
It actually rounds toward zero, which is how BlitzMax converts floating point values to integer.
Here is an alternate version of Rand() which uses Floor() to enforce the correct rounding.
I haven't seriously tested this, but it seems like it should work.
Function Rand2( min_value,max_value=1 ) Local delta!=Double(max_value)-Double(min_value) If delta>0 Return Floor( RndDouble()*(1+delta) ) + min_value Return Floor ( RndDouble()*(1-delta) ) + max_value End Function