Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^7: Small Perl 6 discoveries II, Rats

by Anonymous Monk
on Sep 28, 2017 at 14:22 UTC ( [id://1200277]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Small Perl 6 discoveries II, Rats
in thread [Perl6] Small discoveries I, __DATA__

Am I allowed to subtract a rational from a float if I explicitly convert it to a float first? Pretty please?
> 3e-1 - Num(.3) 5.55111512312578e-17
Oh look, I got the same answer. Also, Perl6's printf lies.
> printf "%.100f\n", .3 0.30000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000 > printf "%.100f\n", 3e-1 0.30000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000 > printf "%.100f\n", Num(.3) 0.30000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000
But you can still get an honest printf with Inline::Perl5.
use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.run('sub p { printf "%.100f\n", shift }'); $p5.call('p', .3); $p5.call('p', Num(.3)); $p5.call('p', 3e-1); =finish 0.29999999999999998889776975374843459576368331909179687500000000000000 +00000000000000000000000000000000 0.29999999999999998889776975374843459576368331909179687500000000000000 +00000000000000000000000000000000 0.30000000000000004440892098500626161694526672363281250000000000000000 +00000000000000000000000000000000

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1200277]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found