Subject: ldexp NetBSD 3.0 amd64 bug
To: None <port-amd64@NetBSD.org>
From: Brendon Costa <bcosta@avdat.com.au>
List: port-amd64
Date: 03/21/2006 09:20:04
-----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;
}

prints the result (on amd64 port):

0 * 2 ^ 0 = 0
0 * 2 ^ 1 = 0
0 * 2 ^ 2 = 0
0 * 2 ^ 3 = 0
0 * 2 ^ 4 = 0
0.5 * 2 ^ 0 = 0.5
0.5 * 2 ^ 1 = 0.5
0.5 * 2 ^ 2 = 0.5
0.5 * 2 ^ 3 = 0.5
0.5 * 2 ^ 4 = 0.5
1 * 2 ^ 0 = 1
1 * 2 ^ 1 = 1
1 * 2 ^ 2 = 1
1 * 2 ^ 3 = 1
1 * 2 ^ 4 = 1
1.5 * 2 ^ 0 = 1.5
1.5 * 2 ^ 1 = 1.5
1.5 * 2 ^ 2 = 1.5
1.5 * 2 ^ 3 = 1.5
1.5 * 2 ^ 4 = 1.5
2 * 2 ^ 0 = 2
2 * 2 ^ 1 = 2
2 * 2 ^ 2 = 2
2 * 2 ^ 3 = 2
2 * 2 ^ 4 = 2

Where it should look like (on i386):
0 * 2 ^ 0 = 0
0 * 2 ^ 1 = 0
0 * 2 ^ 2 = 0
0 * 2 ^ 3 = 0
0 * 2 ^ 4 = 0
0.5 * 2 ^ 0 = 0.5
0.5 * 2 ^ 1 = 1
0.5 * 2 ^ 2 = 2
0.5 * 2 ^ 3 = 4
0.5 * 2 ^ 4 = 8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