t0ddie Posted December 12, 2004 Share Posted December 12, 2004 $flash = random(0,1) i want the value of flash to be "0" or "1" and this wasnt working. i put a message box in there, and its splitting it into decimals. how do i make it just whole numbers? so i get one or zero, and not some decimal in between them like 0.687234987234 thanks T0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
MHz Posted December 12, 2004 Share Posted December 12, 2004 (edited) Also use the Round function to make it whole numbers only.Little example here Edited December 12, 2004 by MHz Link to comment Share on other sites More sharing options...
Helge Posted December 12, 2004 Share Posted December 12, 2004 Untested, but should work :$nr = Random(0,1) $nr = Round($nr,0) MsgBox(64,"0/1",$nr)PS!It`s always smart to check the "Related"-functions when wonderingabout a function. Under Random you would have found Round... Link to comment Share on other sites More sharing options...
ezzetabi Posted December 12, 2004 Share Posted December 12, 2004 (edited) If you have to calc a single number it does not change, but otherwise it is much better using Int() than Round() since it is much faster. I made a small func, it may be useful often. MsgBox(0,'',_RandomInt(0,1)) Func _RandomInt($iMin,$iMax) If $iMax < $iMin Then Return Int($iMin) Return Int(Random($iMin,$iMax + 1)) EndFunc Edited December 12, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
t0ddie Posted December 12, 2004 Author Share Posted December 12, 2004 good stuff guys Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now