Re: weird math
From: Andrew Gaffney (agaffney_at_skylineaero.com)
Date: 05/28/04
- Next message: Roberto Etcheverry: "Re: regex help"
- Previous message: Andrew Gaffney: "regex help"
- In reply to: Kevin Old: "Re: weird math"
- Next in thread: Paul Johnson: "Re: weird math"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 May 2004 14:56:04 -0500 To: Kevin Old <kold@kold.homelinux.com>
Kevin Old wrote:
> On Thu, 2004-05-27 at 23:31, Andrew Gaffney wrote:
>
>>I am writing a program to parse a CSV file downloaded from my bank. I have it
>>keep a running balance, but I'm getting a weird total. Apparently, -457.16 +
>>460.93 = 3.76999999999998. But when 20 is subtracted from that, I get -16.23.
>>There are no weird numbers like that in my input data. All numbers have no more
>>than 2 numbers after the decimal point. Here is my code:
>
> [...]
>
>> print "<td>$balance</td></tr>\n";
>
>
> Andrew,
>
> Try using this when you print out the $balance:
>
> printf "%.2f", $balance;
>
> You'll get 3.77.
I was going to use that for output, but I was just curious why it was happening
in the first place. I think all the other posts answered that question.
-- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548
- Next message: Roberto Etcheverry: "Re: regex help"
- Previous message: Andrew Gaffney: "regex help"
- In reply to: Kevin Old: "Re: weird math"
- Next in thread: Paul Johnson: "Re: weird math"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|