Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug with negative numbers in console.log #952

Closed
schalkneethling opened this issue May 28, 2018 · 0 comments
Closed

Possible bug with negative numbers in console.log #952

schalkneethling opened this issue May 28, 2018 · 0 comments
Labels
bug Indicates an unexpected problem or unintended behavior.

Comments

@schalkneethling
Copy link

In PR #949 @goodwin64 pointed out that the last console.log statement actually output -0 in the browsers native console. The JS editor output 0 though so, there is a bug somewhere in the output formatting that discards the -

@schalkneethling schalkneethling added the bug Indicates an unexpected problem or unintended behavior. label May 28, 2018
@schalkneethling schalkneethling self-assigned this May 28, 2018
kenrick95 added a commit to kenrick95/interactive-examples that referenced this issue Jun 4, 2018
schalkneethling pushed a commit that referenced this issue Jun 5, 2018
Fixes #952 

The bug is caused by using [`String(value)` function](https://www.ecma-international.org/ecma-262/6.0/#sec-string-constructor-string-value), which per the spec calls [`ToString(value)`](https://www.ecma-international.org/ecma-262/6.0/#sec-tostring). _ToString(value)_ for number as per defined [at the spec](https://www.ecma-international.org/ecma-262/6.0/#sec-tostring-applied-to-the-number-type) states that

> Number m to String format as follows:
> 2.  If m is +0 or −0, return the String "0".

So, this PR adds the case where if we meet negative zero at `formatOutput`, then return `-0`, else call `String(input)`. Also, more tests are added.
@schalkneethling schalkneethling removed their assignment Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior.
Projects
None yet
Development

No branches or pull requests

2 participants