Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Decimal Increment Bug?

by toolic (Bishop)
on Mar 16, 2018 at 19:28 UTC ( #1211072=note: print w/replies, xml ) Need Help??


in reply to Decimal Increment Bug?

This is a FAQ Why am I getting long decimals (eg, 19.9499999999999) instead of the numbers I should be getting (eg, 19.95)? Use printf:
use warnings; use strict; my $i = 0.1; my $v = 0 - $i; while ( $v < 9 ) { $v += $i; printf "%.1f%s", $v, $/; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2020-10-30 19:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (283 votes). Check out past polls.

    Notices?