Re:What should every programmer know about programming?
by Erwin on Wednesday September 15, 2010 @07:04PM
(#1696184)
The result of this is a 64-bit double (there are no other numeric data types in JS and this is the data type regardless of the underlying CPU architecture). That has just under 16 digits of precision so the above code will not lose much by multiplying by 10^16 and rounding.
Why would you think this this calculation would get clamped to the range of a signed 32-bit integer?
ord=Math.random()*10000000000000000;
A) It's unnecessary and will get "trimmed" down to 2147483647 on 32-bit systems. B) Clearly the programmer that wrote this has absolutely no idea that his number is going to require a 64-bit long int (on applicable systems) just to generate a random number to make their URL non-cached. What a waste.
</minor rant>