mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: correctly rounded sqrt
Date: Thu, 15 Mar 2012 12:12:23 -0400	[thread overview]
Message-ID: <20120315161223.GD184@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120315080244.GL5728@port70.net>

On Thu, Mar 15, 2012 at 09:02:44AM +0100, Szabolcs Nagy wrote:
> * Szabolcs Nagy <nsz@port70.net> [2012-03-15 06:30:11 +0100]:
> > * Rich Felker <dalias@aerifal.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


  reply	other threads:[~2012-03-15 16:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-14 16:56 Szabolcs Nagy
2012-03-14 16:57 ` Szabolcs Nagy
2012-03-14 19:01 ` Szabolcs Nagy
2012-03-15  1:46   ` Szabolcs Nagy
2012-03-15  3:23     ` Szabolcs Nagy
2012-03-15  5:07       ` Rich Felker
2012-03-15  5:30         ` Szabolcs Nagy
2012-03-15  8:02           ` Szabolcs Nagy
2012-03-15 16:12             ` Rich Felker [this message]
2012-03-15 18:14               ` Pascal Cuoq
2012-03-15 18:22                 ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120315161223.GD184@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).