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

Re: Multiply with 100 in perl

by choroba (Cardinal)
on Nov 11, 2015 at 17:11 UTC ( [id://1147479]=note: print w/replies, xml ) Need Help??


in reply to Multiply with 100 in perl

$ perl -e 'printf "%.20f\n", 75.600 * 100' 7559.99999999999909050530 $ perl -e 'printf "%.0f\n", 75.600 * 100' 7560

See What Every Programmer Should Know About Floating-Point Arithmetic for more information.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Multiply with 100 in perl
by Anonymous Monk on Nov 11, 2015 at 18:42 UTC

    Just to add a little information, the problem isn't multiplying by 100, it's the 75.6

    $ perl -e 'printf "%.20f\n", 75.600' 75.59999999999999431566

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-19 21:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found