operation precedence bug: lib/msun/src

David Schultz das at FreeBSD.ORG
Fri Jun 28 05:23:48 UTC 2013


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


More information about the freebsd-numerics mailing list