Subject: Re: ldexp NetBSD 3.0 amd64 bug
To: Brendon Costa <email@example.com>
From: Tobias Nygren <firstname.lastname@example.org>
Date: 03/20/2006 23:35:11
Brendon Costa wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> Hi All,
> I just came across a bug in NetBSD 3.0 amd64 port. It may have
> already been fixed in current, but I was unable to test this. The
> problem is with the ldexp() function. It seems to just return the
> value of the float value provided without multiplying it by 2
> ^ exp as expected. Note: It works fine with the i386 port.
> A small test program:
> #include <iostream>
> #include <cmath>
> using namespace std;
> int main()
> for (float f = 0.0f; f < 2.1; f += 0.5f)
> for (int exp = 0; exp < 5; exp++)
> float result = ldexp(f, exp);
> cout << f << " * 2 ^ " << exp << " = " << result << endl;
> return 0;
Can confirm this on 3.99.17.
The problem is actually in scalbn() and not ldexp().
After a glance at the code for scalbn() I'm not really surprised that
there could be bugs lurking within. Wow.