[Israel.pm] Fwd: number imprecision

Peter Gordon peter at pg-consultants.com
Sun Sep 3 04:01:51 PDT 2006


Since $x is the result of a floating point calculation, 
do the following test instead

abs(1-$x) < 0.00000001

Peter

On Sun, 2006-09-03 at 09:50 +0200, Michael Gang wrote:
> Dear All,
> 
> I have encountered a strange calculation in perl.
> I have a value which i get in the function ($x ) and his value is 1 .
> Now i show from the debugger a snippet.
> 
> DB<3> x $x
> 0  1
> DB<4> x 1-$x
>  '-2.22044604925031e-16'
> 
> 
> 
> Has anyone an explanation of it how 1-1=  '-2.22044604925031e-16' ?
> 
> Thanks in advance,
> Michael
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl




More information about the Perl mailing list