Does anyone have or know of a routine for getting a floating point random number, ideally between 0.0 and 1.0?
I know theres an integer routine to be found in Ron's source code, at the moment I'm loading that and dividing, horribly wasteful but I don't know any other way around it.
Thanks
Hi
hope the link helps :)
Link
have a nice day
I checked the link, downloaded the files but I have no idea how to use them.
I've tried compiling the source, but can't understand the errors that come up.
I also tried including the lib and making an inc but I get Unresolved Externals and Invalid Lib errors.
Well thanks everyone for all your help... actually no its not fair to be so sarcastic, after all this message board is incredably helpful.
But as I failed to get any help here I tried to write my own routine. Here it is basically, maybe you could help me with it.
Note. I took the Random procedure from soure if found on Ron's site
.data
RndInit dd 1010111000110111101010011011b
.data?
TmpReal4 Real4 ?
.code
Random proc
; Entry: al = size of random number
; Return: eax = random number, cl bits in size
mov cl,al
xor eax,eax
mov bl,byte ptr RndInit
and bl,1
EVEN
Gen_bit: ; make n bit numbers
shl eax,1
mov edx,RndInit; Copy seed
shr edx,9
xor bl,dl
shr edx,5
xor bl,dl
bt ebx,1 ; Copy bit 1 to carry flag
rcr RndInit,1 ; Rotate seed right 1 bit
setc bl ; Set bl TRUE if carry is set
or al,bl
dec cl
jnz Gen_bit
ret
Random endp
;\/ Sample call of routine \/
mov al, 22
call Random
or eax, 01000000000000000000000000000000b
mov TmpReal4, eax
TmpReal4 will then contain a floating point between 2.0 and 3.0
By my understanding this should have been between 1.0 and 2.0. I can't figure why it is one bigger than it should be, at least according to AoA.
Anyone have any ideas?