[EMAIL PROTECTED] wrote:
>>#!/usr/bin/perl -wl
>>use Math::BigFloat;
>>$x = 37.75;
>>print $x - 33.67 - 4.08;
>>$x = Math::BigFloat->new('37.75');
>>print $x - 33.67 - 4.08;
This seems to work, although there are some odd line returns
You mean the automatic "\n" with every
|
| cc:
|
| Subject:
| cc: [EMAIL PROTECTED]
|
| Subject: Re: trouble with math... driving me nuts.
|
>--|
[EMAIL PROTECTED] wrot
[EMAIL PROTECTED] wrote:
print 37.75 - 33.67 - 4.08 ;
;
I find these things all the time. Is there a particular module I can use
to fix these things?
Take a look at Math::BigFloat, it's an arbitrary length float math package:
#!/usr/bin/perl -wl
use Math::BigFloat;
$x = 37.75;
Hi Peter,
This is a floating point issue. It is a general computing problem and not
just subject to Perl. In decimal form the result
is -0.0017763568.
Generally thats usually acurate enough. Otherwise you could truncate it or
round it to the nearest quadrabillionth.
Cheers,
Levon Bar
MAIL PROTECTED]'" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
|
| cc:
[EMAIL PROTECTED] wrote:
> Luckily I was easily able to recreate the problem. See code below:
>
> print 37.75 - 33.67 - 4.08 ;
> ;
>
> I find these things all the time. Is there a particular
> module I can use
> to fix these things?
>
> Output is
>
> -1.77635683940025e-015
>