Re: [AD] Allegro 4.2 todos |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
> Done, see attached patch.
Looks ok, except maybe:
+<b>AL_RAND</b><br>
+ Optional replacement for rand(), this macro actually uses the libc
+ function but does some rework on the result to guarantee more perceived
+ randomness in the lower 16 bits of it.
The last chunk of the sentence sounds weird to me, but I'm not a native
English speaker...
In any cases, wait for Peter's word on the patch because he might trash
everything :-)
> The current formula is:
>
> ((rand() >> 8) + (rand() & 0xff00))
>
> As previously suggested on this list. I've found the following formula
> works better under OSX though:
>
> ((rand() >> 16) + rand())
As Ben (IIRC) pointed out, this one is not guaranteed to give a non-negative
result. We must clamp somewhere.
> I've tested other shift values between 8 and 16, but the best remains 16.
Then
((rand() >> 16) + (rand() & 0x3fffffff) ?
> So I wonder: is this due to the machine endianess or just OSX rand()
> implementation? I think the latter, but could someone test the thing under
> another big endian machine and report the results?
I think it is simply the particular implementation of the OS.
--
Eric Botcazou