SPUG: S.O.S: Sum-Of-Squares (nickname:Help)

Yitzchak Scott-Thoennes sthoenna at efn.org
Fri Oct 3 01:22:01 CDT 2003


On Thu, Oct 02, 2003 at 09:20:19AM -0700, "Mathew D. Watson" <matw at eclipse-optics.com> wrote:
> So now I have a question for the PERL experts out there. Is there a way to
> _really_know_ what the bit pattern of $sos is? If there is, then we can bit
> by bit check our arithmetic. I've done this before in C, and what I recall
> is that printf() (print in Perl) should not be implicitly trusted. For
> example, print "1.0 = ", 1.0; results in the output "1.0 = 1", which is
> correct this time, but the author of print didn't guarantee this is always
> the case. What I'd like to see (and my Perl skills are too weak to do) is
> something like a 'bit capture' of $sos followed by bit ANDs with binary 1
> followed by a bit shift all printed out within a loop (Yes, I trust the
> output of print 1;).

I didn't understand that last part; what is it that you want again?.
He had a number not-quite-equal to 1 and subtracted it from 1.  That
left him with -(2**-52), so his original number was 1+2**-52, i.e. the
next representable number after 1.  So we know just the lowest bit of
the [1] mantissa was wrong.  (Fred said he had a case where the error
was twice as large.  That would be the second-lowest bit being wrong.)

[1] http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=mantissa



More information about the spug-list mailing list