views:

90

answers:

1

What is the precision of JavaScript's Math.random() function?

Thanks!

+2  A: 

Math.random() generates a floating point number of 16 decimal places greater than or equal to zero and less than 1.

krs1
Javascript floating point numbers are 64-bit IEEE 754 values, so it's not *exactly* 16 decimal places.
Pointy
How wouldn't it be exact?
volatile900
@volatile: If your precision is not a power of 10.
Brian
@Pointy This is true, I was imprecise in my answer. bump.
krs1