While using Math.random of javascript, I came across a interesting question.
According to the docs, it produces a "pseudo-random number in the range 0 to less than 1", but what is the biggest number, less than 1 it can produce?
I made this silly code to try getting the highest value
maxIteration = 1000000000
value = 0
count = 0
while(value < 1 && count++ < maxIteration) {
let newValue = Math.random()
value = value < newValue ? newValue : value
}
console.log('value', value)
console.log('count', count)
The highest I could get is 0.9999999989486876, but is it the highest?