Asked 10 years, 9 months ago
Viewed 18k times
Using Node.js, I'm evaluating the expression:
0 < Number.MIN_VALUE
To my surprise, this returns true
. Why is that? And: How can I get the smallest number available for which the comparison works as expected?
asked Oct 28, 2014 at 17:29
Golo RodenGolo Roden152k102102 gold badges316316 silver badges444444 bronze badges
3Number.MIN_VALUE
is 5e-324
, i.e. the smallest positive number that can be represented within float precision, i.e. that's as close as you can get to zero. It defines the best resolution floats give you.
Now the overall smallest value is Number.NEGATIVE_INFINITY
although that's not really numeric in the strict sense.
answered Oct 28, 2014 at 17:35
back2dosback2dos15.6k3636 silver badges5252 bronze badges
3Number.MIN_VALUE
is equivalent to 5e-324 , which is greater than 0.
answered Oct 28, 2014 at 17:36
Mukund KumarMukund Kumar23.4k2020 gold badges6363 silver badges8484 bronze badges
1Since Number.MIN_VALUE = 5e-324 = 5 x 10^-324
and it's greater than 0
(a little bit greater).
Read more here
.
answered Oct 28, 2014 at 17:34
Amir PopovichAmir Popovich30.1k99 gold badges5858 silver badges102102 bronze badges
2`Number.MIN_VALUE` is equal to 5e-324 or 5*(10^-324);
it's math. any positive number is greater than zero.
answered Sep 5, 2022 at 7:30
Use -Number.MAX_VALUE
instead of Number.MIN_VALUE to compare:
0 > -Number.MAX_VALUE
returns true
.
answered Jul 19, 2017 at 2:57
Sean YangSean Yang7511 silver badge66 bronze badges
1Start asking to get answers
Find the answer to your question by asking.
Ask questionExplore related questions
See similar questions with these tags.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4