On 9/2/10 Thu Sep 2, 2010 12:52 PM, "Jim" <j...@lowcarbfriends.com> scribbled:
> On 9/2/2010 2:51 PM, Ruud H.G. van Tol wrote: >> On 2010-09-02 15:32, Jim wrote: >> >>> I was hoping I'd see some answer like... oh yeah... perl is smart enough >>> to handle that for you if you are willing to accept a performance hit... >> >> My "bigrat" was meant like that. Did you already try it? >> >> #!/usr/bin/perl >> use strict; >> use warnings; >> use bigrat; >> >> <your code> >> >> __END__ >> >> > > Sorry, I glanced over your advice. But both bigrat and bignum both > transparently do what I had hoped for. bigint looks like it truncates to > integers which is not a choice for my current problem. > > Does anyone have significant experience with both bigrat and bignum such > that you would advise of use of one over the other. They seem to be very > similar. > > Thank you. I'll work use of one of these into a bit of code at a time to > watch for any side effects. Do you have any evidence that the use of either of these is warranted? So far, you have only shown that printing floating-point numbers to some limited precision involves rounding and can produce unexpected results. You have not shown that the results are wrong, only that you expected something else. 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. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/