A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/26614728/why-is-0-less-than-number-min-value-in-javascript below:

node.js - Why is 0 less than Number.MIN_VALUE in JavaScript?

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 Roden

152k102102 gold badges316316 silver badges444444 bronze badges

3

Number.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

back2dosback2dos

15.6k3636 silver badges5252 bronze badges

3

Number.MIN_VALUE is equivalent to 5e-324 , which is greater than 0.

answered Oct 28, 2014 at 17:36

Mukund KumarMukund Kumar

23.4k2020 gold badges6363 silver badges8484 bronze badges

1

Since 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 Popovich

30.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 Yang

7511 silver badge66 bronze badges

1

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore 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