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

One digit short to correctly stringify a double #5005

Closed
p6rt opened this issue Jan 6, 2016 · 5 comments
Closed

One digit short to correctly stringify a double #5005

p6rt opened this issue Jan 6, 2016 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 6, 2016

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

Searchable as RT127184$

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

From dankogai@dan.co.jp

Folks,

Rakudo needs to add one more digit for each Num it stringifies.

  % perl6 -e 'pi.say'
  3.14159265358979
  % ruby -e 'puts Math​::PI'
  3.141592653589793

As a result…

  % perl6
  > 3.14159265358979 == pi
  False
  > 3.141592653589793 == pi
  True

I consider this more severe than perl5 because​:

  > :​:('&EVAL')(pi.perl) == pi
  False

FYI perl5 has the same problem.

  https://rt.perl.org/Public/Bug/Display.html?id=127182

Please also consider adding hexadecimal floating point notation support (and make .perl happier).

Yours,

Dan the Bit-Picking Rakudo Monger

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

From @lizmat

On 06 Jan 2016, at 13​:47, Dan Kogai (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Dan Kogai
# Please include the string​: [perl #​127184]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127184 >

Folks,

Rakudo needs to add one more digit for each Num it stringifies.

% perl6 -e 'pi.say'
3.14159265358979
% ruby -e 'puts Math​::PI'
3.141592653589793

As a result…

% perl6

3.14159265358979 == pi
False
3.141592653589793 == pi
True

I consider this more severe than perl5 because​:

:​:('&EVAL')(pi.perl) == pi
False

It seems that currently stringification of Nums is done with this​:

  multi method Str(Num​:D​:) {
  nqp​::p6box_s(nqp​::unbox_n(self));
  }

Adding an nqp​::sprintf(‘%.15f’) in there, only makes the parsing of core settings infiniloop.

So looks like this is going to need to be fixed at nqp level.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

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

@p6rt
Copy link
Author

p6rt commented Mar 26, 2018

From @zoffixznet

On Wed, 06 Jan 2016 04​:47​:03 -0800, dankogai wrote​:

Folks,

Rakudo needs to add one more digit for each Num it stringifies.

% perl6 -e 'pi.say'
3.14159265358979
% ruby -e 'puts Math​::PI'
3.141592653589793

As a result…

% perl6

3.14159265358979 == pi
False
3.141592653589793 == pi
True

I consider this more severe than perl5 because​:

:​:('&EVAL')(pi.perl) == pi
False

FYI perl5 has the same problem.

https://rt.perl.org/Public/Bug/Display.html?id=127182

Please also consider adding hexadecimal floating point notation
support (and make .perl happier).

Yours,

Dan the Bit-Picking Rakudo Monger

Thank you for the report. This is now fixed.

Fix​: MoarVM/MoarVM@067c0594103a025
  MoarVM/MoarVM@8841c4241b4faa8
  MoarVM/MoarVM@af2eb8a7f7d4344
  MoarVM/MoarVM@4d3fc2818d0032b
  rakudo/rakudo@8422d7b4e23678b
  rakudo/rakudo@a2a2a745c4242d1
Test​: Raku/roast@589e30a8e809bba7f

@p6rt
Copy link
Author

p6rt commented Mar 26, 2018

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

@p6rt p6rt closed this as completed Mar 26, 2018
@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