Thanks - the raku and gist methods were what I needed to locate and comprehend.
$ raku -e 'my $r = 3602879701896397/36028797018963968; say $r.raku; sa
+y $r.raku == $r;'
0.1000000000000000055511151231257827021181583404541015625
True
This is much more like what I expected of the raku language.
I'm surprised that the gist method sacrifices accuracy so readily. Even 1/128 does not render the exact value, providing 0.007813 instead of 0.0078125.
But that's a matter of choice - I now see nothing buggy happening there.
As regards converting a double to its exact rational representation, this is quite simple in perl:
$ perl -le 'printf "%.800g\n", 0.1'
0.1000000000000000055511151231257827021181583404541015625
$
Is the same thing also as straightforward in raku ?
I tried:
$ raku -e 'printf "%.800g\n", 0.1e0'
NaN
$
I've read documentation stating that raku's printf() expects that the last argument must be a string.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.