Jump to content

small help with random


t0ddie
 Share

Recommended Posts

$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

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 by ezzetabi
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...