September 25, 2012 2:41 PM Subscribe

JavaScript question: What is the lowest number and what is the highest number generated by Math.random()?— 0.0000000000000000 or 0.0000000000000001, 1.0000000000000000 or 0.9999999999999999

posted by markcmyers to Technology (3 answers total) 1 user marked this as a favorite

posted by markcmyers to Technology (3 answers total) 1 user marked this as a favorite

Mozilla Developer Network:

Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive), which you can then scale to your desired range.posted by Foci for Analysis at 2:45 PM on September 25, 2012

Note that as numbers in JavaScript are IEEE 754 floating point numbers with round-to-nearest-even behavior, these ranges, excluding the one for Math.random() itself, aren't exact, and depending on the bounds it's possible in extremely rare cases (on the order of 1 in 262) to calculate the usually-excluded upper bound.

This thread is closed to new comments.

Returns a floating-point, pseudo-random number in the range [0, 1) that is, from 0 (inclusive) up to but not including 1 (exclusive).

posted by Tomorrowful at 2:45 PM on September 25, 2012