Merge pull request #376 from TsudaKageyu/test-float80

Added a missing test for ByteVector::toFloat80().
This commit is contained in:
Lukáš Lalinský 2014-04-10 20:10:39 +02:00
commit fbbebfcec6
2 changed files with 11 additions and 8 deletions

View File

@ -785,7 +785,7 @@ double ByteVector::toFloat64BE(size_t offset) const
return 0.0;
}
else
val = ::ldexp(1.0 + static_cast<double>(fraction), exponent - 1023 - 52);
val = ::ldexp(static_cast<double>(fraction), exponent - 1023 - 52);
}
if(negative)

View File

@ -178,16 +178,19 @@ public:
CPPUNIT_ASSERT(ByteVector::fromUInt16LE(4386) == ByteVector::fromUInt16BE(8721));
CPPUNIT_ASSERT(ByteVector::fromUInt32LE(287454020) == ByteVector::fromUInt32BE(1144201745));
CPPUNIT_ASSERT(ByteVector::fromUInt64LE(1234605615291183940) == ByteVector::fromUInt64BE(4914309075945333265));
const uchar PI32[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb };
const uchar PI64[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 };
const uchar PI32[] = { 0x00, 0x40, 0x49, 0x0f, 0xdb };
const uchar PI64[] = { 0x00, 0x40, 0x09, 0x21, 0xfb, 0x54, 0x44, 0x2d, 0x18 };
const uchar PI80[] = { 0x00, 0x40, 0x00, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc0, 0x00 };
ByteVector pi32(reinterpret_cast<const char*>(PI32), 5);
CPPUNIT_ASSERT(static_cast<int>(pi32.toFloat32BE(1) * 100) == 314);
ByteVector pi32(reinterpret_cast<const char*>(PI32), 5);
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi32.toFloat32BE(1) * 10000));
ByteVector pi64(reinterpret_cast<const char*>(PI64), 9);
CPPUNIT_ASSERT(static_cast<int>(pi64.toFloat64BE(1) * 100) == 314);
ByteVector pi64(reinterpret_cast<const char*>(PI64), 9);
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi64.toFloat64BE(1) * 10000));
ByteVector pi80(reinterpret_cast<const char*>(PI80), 11);
CPPUNIT_ASSERT_EQUAL(31415, static_cast<int>(pi80.toFloat80BE(1) * 10000));
}
void testReplace()