[Israel.pm] Number imprecision

Michael Gang michaelgang at gmail.com
Mon Sep 4 02:25:28 PDT 2006


Dear Mr Gordon,

What I am making in this case sqrt(1- $x) ?
Should I add a small number like this sqrt(1.000000001-$x) or is there
a more elegant answer ?

Best regards,
Michael
On 9/4/06, perl-request at perl.org.il <perl-request at perl.org.il> wrote:
> Send Perl mailing list submissions to
>         perl at perl.org.il
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://perl.org.il/mailman/listinfo/perl
> or, via email, send a message with subject or body 'help' to
>         perl-request at perl.org.il
>
> You can reach the person managing the list at
>         perl-owner at perl.org.il
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Perl digest..."
>
>
> Today's Topics:
>
>    1. Re: Fwd: number imprecision (Peter Gordon)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 03 Sep 2006 14:01:51 +0300
> From: Peter Gordon <peter at pg-consultants.com>
> Subject: Re: [Israel.pm] Fwd: number imprecision
> To: Perl in Israel <perl at perl.org.il>
> Message-ID: <1157281311.2705.15.camel at tigger>
> Content-Type: text/plain
>
> 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
>
>
>
> ------------------------------
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl
>
>
> End of Perl Digest, Vol 42, Issue 3
> ***********************************
>



More information about the Perl mailing list