Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Decimal Increment Bug?

by toolic (Bishop)
on Mar 16, 2018 at 19:28 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1211072]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found