What is the lowest number and what is the highest number generated by Math.random()? September 25, 2012 2:41 PMSubscribe

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

One of the first results I found for "javascript math.random" was from the Mozilla documentation:

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.

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.

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