Another way is to count the bits, as in the following:

.sub _main
        N1 = 1
        N2 = 0.5
        I0 = 0
REPEAT:
        I0 = I0 + 1
        N2 = N2 / 2
        N3 = N1 + N2
        ne N1, N3, REPEAT

        print I0
        print " bits precision\n"
        end
        .end



On Wed, 17 Nov 2004 01:13:21 +1300, Adam Warner <[EMAIL PROTECTED]> wrote:
> Hi Leopold Toetsch,
> 
> >> PI is (very) approximately:
> >   3.141590653589694692726652647252194583415985107421875000000000
> >          ^^^^^
> >   3.141592653589793238462643383279502884197169399375105820974944
> >
> > You might probably want to run more iterations ;) And you'll never get
> > 60 digits out of long doubles.
> 
> I appreciate that Leopold. I thought the zeros indicated where the stored
> value cuts off. But with 52 significant figures at ~3.3 bits per figure
> that's about 172 bits, which indicates they would have to be 256 bit
> floats when including the exponent (my mistake in calling them 128 bit)!
> 
> In other words sprintf is printing trailing garbage:
> 
> .sub _main
>         set     N1, 2.0
>         set     N2, 3.0
>         div     N1, N1, N2
>         new     P0, .PerlArray
>         set     P0, 1
>         set     P0[0], N1
>         sprintf S0, "%.60f\n", P0
>         print   S0
>         end
> .end
> 
> On the CVS version I compiled this prints:
> 0.666666666666666629659232512494781985878944396972656250000000
> 
> On this win32 release (running on a different machine):
> http://www.jwcs.net/developers/perl/pow/download/pow-0.1.1-release.zip
> parrot prints:
> 0.666666666666666630000000000000000000000000000000000000000000
> 
> Regards,
> Adam
> 
>

Reply via email to