[Israel.pm] Number imprecision

Peter Gordon peter at pg-consultants.com
Tue Sep 5 04:11:33 PDT 2006


So if we go that route, and $x is in the range 0-.9999, then int(1-$x)
gives that value as 0. It's a nice round number, but does it give the
right result?



On Tue, 2006-09-05 at 13:09 +0300, Levenglick Dov-RM07994 wrote:
> While you are at it, why not take the sqrt of the cosine of the inverse
> matrix?
> I suggest using int(1-$x) 
> 
> 
>  
> Best Regards,
> Dov Levenglick
> DSP SoC System and Applications Engineer,
> Network and Computing Systems Group
> Freescale Semiconductor Israel
> Tel. +972-9-952-2804
> The information contained in this email is classified as:
> [ ] Freescale General Business Information
> [ ] Freescale Internal Use Only
> [ ] Freescale Confidential Proprietary
> [x] Personal Memorandum
> 
> -----Original Message-----
> From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
> Behalf Of Peter Gordon
> Sent: Tuesday, September 05, 2006 12:39
> To: Perl in Israel
> Cc: Michael Gang
> Subject: Re: [Israel.pm] Number imprecision
> 
> There is a concern that 1-$x might go negative, so how about
> sqrt(abs(1-$x)) 
> 
> Regards,
> 
> Peter
> 
> On Mon, 2006-09-04 at 11:25 +0200, Michael Gang wrote:
> > 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>am ma
> 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
> > > ***********************************
> > >
> > _______________________________________________
> > 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
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl




More information about the Perl mailing list