This seems like a totally stupid question that I can't find the answer to. How to I get a random float?
I have found random() is not a number at all, but some random set of binary bits, is that right?
This gives an integer it seems, ranged 1 -100.
But how do I get a random float, ranged 0-1? In most other languages I have used a call to rand() will simply return just that. It is then up to you to make an integer or make that value fit your desired range.
I'm sure this is a silly question, but my Objective-C noobness, and Google, are failing me.
I have found random() is not a number at all, but some random set of binary bits, is that right?
This gives an integer it seems, ranged 1 -100.
Code:
random() % 100
But how do I get a random float, ranged 0-1? In most other languages I have used a call to rand() will simply return just that. It is then up to you to make an integer or make that value fit your desired range.
I'm sure this is a silly question, but my Objective-C noobness, and Google, are failing me.