Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 15 Mar 2012 09:02:44 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: correctly rounded sqrt

* 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

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.