Home  |  Linux  | Mysql  | PHP  | XML
From:Jim Gibson Date:Thu Sep  2 21:34:57 2010
Subject:Re: floating point precision
On 9/2/10 Thu Sep 2, 2010 2:00 PM, "Jim" <jim@lowcarbfriends.com>
scribbled:

> On 9/2/2010 4:15 PM, Jim Gibson wrote:

>> My advice is to stay away from these modules unless you know what you are
>> doing. I find that double-precision floating-point arithmetic is always good
>> enough. I have been programming in scientific and technical fields for 40
>> years and have yet to need extended-precision arithmentic.
>>
>> If, on the other hand, you are working with large, financial transactions or
>> cryptography, you may need these modules. If that is the case, however, you
>> probably shouldn't be looking for help on a Perl beginner's list.
>>
>> I just do not want anybody to get the impression that these modules are
>> needed for accurate arithmetic in Perl and that standard Perl arithmetic
>> operations are inaccurate.
>
> I'm open to more advice. How would you rewrite my original toy code?

I wouldn't. It doesn't contain any errors. What you are seeing is the
expected behavior. The internal representation of most floating-point
numbers is approximate. If you print out binary floating-point numbers at
enough precision you will see differences from decimal representations. If
you are using double-precision floating-point, the accuracy is about 16
decimal places. If you need more accuracy than that, then you need to use
extended precision. But those applications are rare.


Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
Re: help on example from "mastering algorithm with perl" on binary search
Re: Rendering data structures using CGI::Application
AW: AW: friend class in perl
Re: Traversing Hash printing two times
Re: Need help with Mail::Sender



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants