How to find the sign of a value?

Blitz3D Forums/Blitz3D Programming/How to find the sign of a value?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

push and poping?
IF is likely to use as much time!

The Sgn function would most likely look something like this (except in machine code and not basic)
Function Sgn%(number#)

If number# < 0 Then Return 0
Return 1

End Function


Which is basically what the routine did before with If a < 0 except that now you're adding the overhead of a function call and you still need to use the If statement to compare the result of the Sgn function. So yes, it would be slower. After some time testing, I've found that it is more than twice as slow.

Now the difference is only a fraction of a millisecond, so for 99% of your programs, it really won't make any performance difference, but if you're using it several times in your main game loop, that small difference could be what determines if your game will run smoothly on your friend's Pentium II 750. :)