deul
deul

Reputation: 13

Number.EPSILON and Number.MIN_VALUE. Why are two different?

Number.EPSILON The smallest interval between two representable numbers.

Number.MIN_VALUE The smallest positive representable number - that is, the positive number closest to zero (without actually being zero).

Min_Value is the smallest positive number that can be represented.

Epsilon is the minimum interval between two representable numbers.

Why is Epsilon the not closest to zero?

Number.EPSILON === Number.MIN_VALUE false

Number.EPSILON 2.220446049250313e-16

Number.MIN_VALUE 5e-324

Upvotes: 1

Views: 717

Answers (1)

Dimitri Mockelyn
Dimitri Mockelyn

Reputation: 1545

The definition of Number.EPSILON is slightly different than that :

The Number.EPSILON property represents the difference between 1 and the smallest floating point number greater than 1.

The difference here is representable vs difference (measurable)

In Javascript, numbers are stored in the IEEE 754 Standard, meaning we can represent very small and large values, but only "approximately". For very big numbers, the addition or subtraction operation will not be exact, since the representation is not exact. It's the same if we want to add or substract very "little" numbers. Number.EPSILON can be used to compare floating numbers, so we cannot use an "approximative" representation for that.

Upvotes: 2

Related Questions