develooper Front page | perl.perl5.porters | Postings from September 2000

Re: [ID 20000917.004] Internal floating-point rounding error?

Thread Previous
From:
Nick Ing-Simmons
Date:
September 18, 2000 00:53
Subject:
Re: [ID 20000917.004] Internal floating-point rounding error?
Message ID:
200009180752.IAA13472@mikado.tiuk.ti.com
Philip Andrew <Philip.Andrew@stanfordalumni.org> writes:
>
>(adding 1/10 of my resolution to the number), but what's the
>point -- the round-off is supposed to be correct, isn't it?

perl (like the C it is built upon) has float -> int as truncate toward
zero not round. Your '%04d' forces integer. If you use %f or %g 
then round should be to nearest (decimal) and hence "correct".

-- 
Nick Ing-Simmons <nik@tiuk.ti.com>
Via, but not speaking for: Texas Instruments Ltd.


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About