[Bf-committers] note to developers about 32 vs 64 bit long datatypes

Lukas Tönne lukas.toenne at googlemail.com
Wed Oct 26 11:33:45 CEST 2011


Oops, forgot the link:

[1]
http://en.wikipedia.org/wiki/Linear_congruential_generator

On Wed, Oct 26, 2011 at 11:33 AM, Lukas Tönne
<lukas.toenne at googlemail.com> wrote:
> I recently came across a similar issue when working on random number
> generation for particles. I copied part of the code in
> BLI_rand.h/rand.c, which uses the common linear congruential generator
> [1]. In order to create random numbers over the full 32-bit integer
> range, the internal state variable must be a 64-bit integer, and to
> ensure this the code uses different typedefs depending on OS:
>
> #if defined(WIN32) && !defined(FREE_WINDOWS)
> typedef unsigned __int64        r_uint64;
> #else
> typedef unsigned long long      r_uint64;
>
> I don't know if this code even takes Win64 into account ... but
> according to the standard the awkward "unsigned long long" type should
> have *at least* 64 bits.
> Imo it would be nice to have a general, reliable, platform-independent
> 64 bit typedef for this sort of thing.
>
> On Tue, Oct 25, 2011 at 11:42 PM, pete larabell <xgl.asyliax at gmail.com> wrote:
>> Hey all, was debugging a new node im making and some discussion on IRC
>> lead me to find this:
>>
>> http://en.cppreference.com/w/cpp/language/types
>>
>> Note that unsigned long, and long are truly DIFFERENT sizes on Win64
>> vs Linux64/FreeBSD64/OSX64
>>
>> Not sure if anyone else ran into a problem like this, but I thought it
>> was worth bringing up to everyone that may be expecting something a
>> certain size (for filling out a struct or whatever), it's different
>> depending on the platform you compile on.
>>
>> Cheers!
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
>


More information about the Bf-committers mailing list