Date: Thu, 27 Jun 2013 21:58:29 -0700 From: David Schultz <das@FreeBSD.ORG> To: Eitan Adler <lists@eitanadler.com> Cc: freebsd-numerics@freebsd.org Subject: Re: operation precedence bug: lib/msun/src Message-ID: <20130628045829.GA3590@zim.MIT.EDU> In-Reply-To: <CAF6rxg=7AQ-5qnOu0_neZMG-=xQTL5wjM%2Bt_qopeVN4uxg8g5w@mail.gmail.com> References: <CAF6rxg=7AQ-5qnOu0_neZMG-=xQTL5wjM%2Bt_qopeVN4uxg8g5w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jun 19, 2013, Eitan Adler wrote: > Does the following look correct? [...] > diff --git a/lib/msun/src/s_fma.c b/lib/msun/src/s_fma.c [...] > - if (bits_lost != 1 ^ (int)(hibits & 1)) { > + if (bits_lost != (1 ^ (int)(hibits & 1))) { No, logical xor is intended: If we lost one bit due to denormalization, we need to adjust if the low bit is 1, and if we lost more than one bit, we need to adjust if the low bit is 0. I apologize for writing 6 lines of code that would take pages to explain. The relevant background (guard and sticky bits) is covered in the following book chapter if you're interested: http://uenics.evansville.edu/~mr56/ece752/AppendixH.pdf
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130628045829.GA3590>