t0ddie 0 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. Share this post Link to post Share on other sites
MHz 80 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 Share this post Link to post Share on other sites
Helge 3 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... Share this post Link to post Share on other sites
ezzetabi 3 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 Share this post Link to post Share on other sites
t0ddie 0 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. Share this post Link to post Share on other sites