Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is the minimal value greater than zero?

I was just testing numbers in JavaScript when I noticed something weird occurring.

Why is Number.MIN_VALUE greater than 0? I expected it to be a very small negative value.

console.log(Number.MIN_VALUE > 0);

Is there some mathematics behind it, or is it a JavaScript precision error?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The value of Number.MIN_VALUE is equal to 5e-324. This can be shown below.

console.log(Number.MIN_VALUE);

As you can see, the value is 5e-324.


This is the smallest positive number that can be shown within float precision (float precision is relating to the 0.1 + 0.2 bug).

This is as close as you can get to 0.


The technical smallest value is Number.NEGATIVE_INFINITY.

console.log(Number.NEGATIVE_INFINITY);

However, this isn’t really "numerical", as the value is -Infinity, which can’t be represented with a clear number.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading