:

bug in ttmath::Big<exp, man>::FromDouble(double) ?

Added by: ~homme_curieux, 2012 X 30

Added by: ~homme_curieux, 2012 X 30

uint FromDouble(double value)
...
UInt<2> m;
...
FromDouble_SetExpAndMan(
(temp.u[1] & 0x80000000u) != 0,
e - 1022 - man*TTMATH_BITS_PER_UINT + 1 - moved, 0,
m.table[1],
m.table[2] // usign insted m.table[0] ???
);

Added by: tomek, 2012 X 30, Last modified: 2012 X 30

Thank you, it was a bug, corrected in trunk. In a few days there'll be a release in sourceforge.

It had an impact on a 32bit platform when the 'double' was in so called 'unnormalized' state, sample program:

union
{
double d;
uint u[2]; // two 32bit words
} temp;

temp.u[0] = 0;
temp.u[1] = 10;

Big<1, 3> a;
a.FromDouble(temp.d);

std::cout << std::setprecision(20) << "double: " << temp.d << std::endl;
std::cout << "ttmath: " << a << std::endl;

above program gave:
double: 2.1219957909652723e-313
ttmath: 2.121995791597676341640934755e-313
so the error was on 8th digit

now it is:
double: 2.1219957909652723e-313
ttmath: 2.121995790965272315111382215e-313
as it shoud be

Thanks