Does anyone know why does JavaScript support both normal zero and negative zero?

Does anyone know why does JavaScript support both normal zero and negative zero?

int x = -0

int y = +0

x === y evaluates to true , so javascript treats them as the same number.

" In the IEEE 754 standard used to represent the Number type in JavaScript, the sign is represented by a bit (a 1 indicates a negative number).

As a result, there exists both a negative and a positive value for each representable number, including 0.

This is why both -0 and +0 exist."

int x = -0

int y = +0

x === y evaluates to true , so javascript treats them as the same number.

" In the IEEE 754 standard used to represent the Number type in JavaScript, the sign is represented by a bit (a 1 indicates a negative number).

As a result, there exists both a negative and a positive value for each representable number, including 0.

This is why both -0 and +0 exist."

It can be used in several scenarios to prevent unwanted information loss.

Like the speed of movement per animation frame where the sign could represent the direction of the movement. If the sign is lost, you will have no way of knowing what direction it was moving in before getting at zero.

It can be used in several scenarios to prevent unwanted information loss.

Like the speed of movement per animation frame where the sign could represent the direction of the movement. If the sign is lost, you will have no way of knowing what direction it was moving in before getting at zero.