Jump to content

Let's play with Number.MIN_VALUE


graduate

Recommended Posts

var min = Number.MIN_VALUE; // make a shortcut (1 + min) === 1; // true; why? the left side should be biggermin * 1e307 + 1 === 1 // true; still truemin * 1e308 + 1 === 1 // false; eureka! now the left side is bigger If you want to use this min value, you can be dissapointedMath.pow(1 + 0.000001, Infinity); // Infinity; all is okMath.pow(1 + min, Infinity); // NaN; because 1 + min == 1 Can you explane what happens? Why 1 + min == 1?

Link to comment
Share on other sites

It looks like a precision error with floating point numbers. Computers don't have infinite digits to work with, so they round off. Aside from that, they have to round it off in binary, which doesn't always work as well. In some cases it will round the result of an operation with min down to 0, while other times it can round it off to a really small number.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...