[Tutor] Can you get python to force a number to remain 32 bit instead of autoconverting to type 'long'?

R. Alan Monroe amonroe at columbus.rr.com
Tue Mar 8 00:47:38 CET 2005


I tried to convert this pseudocode

function IntNoise(32-bit integer: x)
    x = (x<<13) ^ x;
    return ( 1.0 - ( (x * (x * x * 15731 + 789221) + 1376312589) & 7fffffff) / 1073741824.0);    
end IntNoise function

from this website
http://freespace.virgin.net/hugo.elias/models/m_perlin.htm

to python. But it seems to rely on wraparound within the 32 bit int.
Can you duplicate this behavior in python?

Alan



More information about the Tutor mailing list