• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Does GetRandomInt accept zero?

Status
Not open for further replies.
I have no idea how randomization works with computers... the last question I had was why getting a random 'real' number didn't cause the game to crash... logically, I pictured real numbers to have infinite decimal places...

All of the randomization triggers in blizzard.j start with 1 and not 0, so I thought they had a reason for that o_O

you're getting a real number while using GetRandomInt??

if not,
reals can have infinite decimal places but why would they cause a crash, and if they would then I think the makers of warcraft won't even put the action GetRandomReal()...
 

Dr Super Good

Spell Reviewer
Level 65
Joined
Jan 18, 2005
Messages
27,290
Reals are 32 bit floating points I believe. Thus they only have a finite accuracy and so can not crash. Basically a floating point is an approximation of a number, meaning it actually is not exact.

0.1 for example could become 0.100025 so it is truncated for accuracy.

I seriously doubt WC3 uses IEEE complient floating points as speed is more important than precision thus accuracy probably is only a 32 bit float so 4294967296 different numbers capable of being represented. I could be wrong.

Larger numbers lose accuracy in the decimal places, thus how the spread is provided.
 
Status
Not open for further replies.
Top