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

-0 breaks value identity comparison #5373

Closed
p6rt opened this issue Jun 13, 2016 · 4 comments
Closed

-0 breaks value identity comparison #5373

p6rt opened this issue Jun 13, 2016 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 13, 2016

Migrated from rt.perl.org#128395 (status was 'resolved')

Searchable as RT128395$

@p6rt
Copy link
Author

p6rt commented Jun 13, 2016

From zefram@fysh.org

my $a = 0.Num
0
my $b = -$a
-0
$a
0
$b
-0
$a.WHICH
Num|0
$b.WHICH
Num|-0
atan2($a, -1)
3.14159265358979
atan2($b, -1)
-3.14159265358979
$a === $b
True

These two values, the two floating point zeroes, are distinct values, as
shown by their stringification, .WHICH, and atan2 branch cut behaviour.
The === comparison is producing the wrong answer, claiming that they're
the same value. They are of course correctly ==, but === is making a
different kind of comparison. In the related case of NaN compared to
NaN, === correctly says that NaN is the same value as itself, despite
it not being == to itself.

-zefram

@p6rt
Copy link
Author

p6rt commented Nov 26, 2016

From @zoffixznet

On Mon, 13 Jun 2016 03​:20​:34 -0700, zefram@​fysh.org wrote​:

my $a = 0.Num
0
my $b = -$a
-0
$a
0
$b
-0
$a.WHICH
Num|0
$b.WHICH
Num|-0
atan2($a, -1)
3.14159265358979
atan2($b, -1)
-3.14159265358979
$a === $b
True

These two values, the two floating point zeroes, are distinct values, as
shown by their stringification, .WHICH, and atan2 branch cut behaviour.
The === comparison is producing the wrong answer, claiming that they're
the same value. They are of course correctly ==, but === is making a
different kind of comparison. In the related case of NaN compared to
NaN, === correctly says that NaN is the same value as itself, despite
it not being == to itself.

-zefram

Thank you for the report. This is now fixed \o/

rakudo​: rakudo/rakudo@085145f3a5
tests​: Raku/roast@f67de6cf58

@p6rt
Copy link
Author

p6rt commented Nov 26, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Nov 26, 2016
@p6rt
Copy link
Author

p6rt commented Nov 26, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant