Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Rounding over numbers [Perl6]

by u65 (Chaplain)
on Feb 15, 2016 at 16:20 UTC ( [id://1155265]=note: print w/replies, xml ) Need Help??


in reply to Rounding over numbers

Update: Added "Perl6" tag to end of subject.

On my Debian 7, 64-bit system, with Perl 5.14 I see the following results

$ perl -e 'printf "13.24 rounds to %.*f0\n", 1, 13.24'; 13.24 rounds to 13.20 $ perl -e 'printf "13.25 rounds to %.*f0\n", 1, 13.25'; 13.25 rounds to 13.20 $ perl -e 'printf "13.26 rounds to %.*f0\n", 1, 13.26'; 13.26 rounds to 13.30

and using the Perl 6 REPL shows

> say sprintf("13.24 rounds to %.*f0", 1, 13.24); 13.24 rounds to 13.20 > say sprintf("13.25 rounds to %.*f0", 1, 13.25); 13.25 rounds to 13.30 > say sprintf("13.26 rounds to %.*f0", 1, 13.26); 13.26 rounds to 13.30

which I believe is due at least partly to Perl 6's use of rational numbers--a major feature.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-20 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found