Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120315161223.GD184@brightrain.aerifal.cx>
Date: Thu, 15 Mar 2012 12:12:23 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: correctly rounded sqrt

On Thu, Mar 15, 2012 at 09:02:44AM +0100, Szabolcs Nagy wrote:
> * Szabolcs Nagy <nsz@...t70.net> [2012-03-15 06:30:11 +0100]:
> > * Rich Felker <dalias@...ifal.cx> [2012-03-15 01:07:48 -0400]:
> > > .global sqrt
> > > .type sqrt,@function
> > > sqrt:	fldl 4(%esp)
> > > 	fsqrt
> > > 	fstsw %ax
> > > 	sub $12,%esp
> > > 	fld %st(0)
> > > 	fstpt (%esp)
> > > 	mov (%esp),%ecx
> > > 	and $0x7ff,%ecx
> > > 	cmp $0x400,%ecx
> > > 	jnz 1f
> > > 	and $0x200,%eax
> > > 	sub $0x100,%eax
> > > 	sub %eax,(%esp)
> > here you modify the return value even if it was nan
> > eg c99 F.9 recommends no nan modifications
> > if ((y & 0x7fff<<64) == 0x7fff<<64) ...
> > 
> posix requires this as well
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_20
> 
> if (signexp >= 0x7fff) is probably a better check

Haha, this is the second time I stupidly forget sqrt(x) is
nonnegative... :-) Fixing it..

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.