Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Rounding over numbers [Perl6]

by u65 (Chaplain)
on Feb 15, 2016 at 16:20 UTC ( #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
Node Status?
node history
Node Type: note [id://1155265]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2021-04-14 22:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?