#include <CDR_Base.h>
Public Types | |
| typedef long double | NativeImpl |
Public Member Functions | |
| LongDouble & | assign (const NativeImpl &rhs) |
| LongDouble & | assign (const LongDouble &rhs) |
| bool | operator== (const LongDouble &rhs) const |
| bool | operator!= (const LongDouble &rhs) const |
| LongDouble & | operator*= (const NativeImpl rhs) |
| LongDouble & | operator/= (const NativeImpl rhs) |
| LongDouble & | operator+= (const NativeImpl rhs) |
| LongDouble & | operator-= (const NativeImpl rhs) |
| LongDouble & | operator++ () |
| LongDouble & | operator-- () |
| LongDouble | operator++ (int) |
| LongDouble | operator-- (int) |
| operator NativeImpl () const | |
Public Attributes | |
| char | ld [16] |
Definition at line 304 of file CDR_Base.h.
| typedef long double ACE_CDR::LongDouble::NativeImpl |
Definition at line 318 of file CDR_Base.h.
| ACE_CDR::LongDouble & ACE_CDR::LongDouble::assign | ( | const NativeImpl & | rhs | ) |
Definition at line 611 of file CDR_Base.cpp.
{
ACE_OS::memset (this->ld, 0, sizeof (this->ld));
if (sizeof (rhs) == 8)
{
#if defined (ACE_LITTLE_ENDIAN)
static const size_t byte_zero = 1;
static const size_t byte_one = 0;
char rhs_ptr[16];
ACE_CDR::swap_8 (reinterpret_cast<const char*> (&rhs), rhs_ptr);
#else
static const size_t byte_zero = 0;
static const size_t byte_one = 1;
const char* rhs_ptr = reinterpret_cast<const char*> (&rhs);
#endif
ACE_INT16 sign = static_cast<ACE_INT16> (
static_cast<signed char> (rhs_ptr[0])) & 0x8000;
ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) |
((rhs_ptr[1] >> 4) & 0xf);
const char* exp_ptr = reinterpret_cast<const char*> (&exponent);
// Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE
if (exponent == 0x7ff)
{
exponent = 0x7fff;
}
else
{
exponent = (exponent - max_eleven_bit) + max_fifteen_bit;
}
exponent |= sign;
// Store the sign bit and exponent
this->ld[0] = exp_ptr[byte_zero];
this->ld[1] = exp_ptr[byte_one];
// Store the mantissa. In an 8 byte double, it is split by
// 4 bits (because of the 12 bits for sign and exponent), so
// we have to shift and or the rhs to get the right bytes.
size_t li = 2;
bool direction = true;
for (size_t ri = 1; ri < sizeof (rhs);)
{
if (direction)
{
this->ld[li] |= ((rhs_ptr[ri] << 4) & 0xf0);
direction = false;
++ri;
}
else
{
this->ld[li] |= ((rhs_ptr[ri] >> 4) & 0xf);
direction = true;
++li;
}
}
#if defined (ACE_LITTLE_ENDIAN)
ACE_OS::memcpy (rhs_ptr, this->ld, sizeof (this->ld));
ACE_CDR::swap_16 (rhs_ptr, this->ld);
#endif
}
else
{
ACE_OS::memcpy(this->ld,
reinterpret_cast<const char*> (&rhs), sizeof (rhs));
}
return *this;
}
| ACE_CDR::LongDouble & ACE_CDR::LongDouble::assign | ( | const LongDouble & | rhs | ) |
Definition at line 682 of file CDR_Base.cpp.
{
if (this != &rhs)
*this = rhs;
return *this;
}
| ACE_CDR::LongDouble::operator ACE_CDR::LongDouble::NativeImpl | ( | ) | const |
Definition at line 701 of file CDR_Base.cpp.
{
ACE_CDR::LongDouble::NativeImpl ret = 0.0;
char* lhs_ptr = reinterpret_cast<char*> (&ret);
if (sizeof (ret) == 8)
{
#if defined (ACE_LITTLE_ENDIAN)
static const size_t byte_zero = 1;
static const size_t byte_one = 0;
char copy[16];
ACE_CDR::swap_16 (this->ld, copy);
#else
static const size_t byte_zero = 0;
static const size_t byte_one = 1;
const char* copy = this->ld;
#endif
ACE_INT16 exponent = 0;
char* exp_ptr = reinterpret_cast<char*> (&exponent);
exp_ptr[byte_zero] = copy[0];
exp_ptr[byte_one] = copy[1];
ACE_INT16 sign = (exponent & 0x8000);
exponent &= 0x7fff;
// Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE
if (exponent == 0x7fff)
{
exponent = 0x7ff;
}
else
{
exponent = (exponent - max_fifteen_bit) + max_eleven_bit;
}
exponent = (exponent << 4) | sign;
// Store the sign and exponent
lhs_ptr[0] = exp_ptr[byte_zero];
lhs_ptr[1] = exp_ptr[byte_one];
// Store the mantissa. In an 8 byte double, it is split by
// 4 bits (because of the 12 bits for sign and exponent), so
// we have to shift and or the rhs to get the right bytes.
size_t li = 1;
bool direction = true;
for (size_t ri = 2; li < sizeof (ret);) {
if (direction)
{
lhs_ptr[li] |= ((copy[ri] >> 4) & 0xf);
direction = false;
++li;
}
else
{
lhs_ptr[li] |= ((copy[ri] & 0xf) << 4);
direction = true;
++ri;
}
}
#if defined (ACE_LITTLE_ENDIAN)
ACE_CDR::swap_8 (lhs_ptr, lhs_ptr);
#endif
}
else
{
ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret));
}
// This bit of code is unnecessary. However, this code is
// necessary to work around a bug in the gcc 4.1.1 optimizer.
ACE_CDR::LongDouble tmp;
tmp.assign (ret);
return ret;
}
| bool ACE_CDR::LongDouble::operator!= | ( | const LongDouble & | rhs | ) | const |
Definition at line 696 of file CDR_Base.cpp.
{
return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0;
}
| LongDouble& ACE_CDR::LongDouble::operator*= | ( | const NativeImpl | rhs | ) | [inline] |
Definition at line 329 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) * rhs);
}
| LongDouble& ACE_CDR::LongDouble::operator++ | ( | void | ) | [inline] |
Definition at line 341 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) + 1);
}
| LongDouble ACE_CDR::LongDouble::operator++ | ( | int | ) | [inline] |
Definition at line 347 of file CDR_Base.h.
{
LongDouble ldv = *this;
this->assign (static_cast<NativeImpl> (*this) + 1);
return ldv;
}
| LongDouble& ACE_CDR::LongDouble::operator+= | ( | const NativeImpl | rhs | ) | [inline] |
Definition at line 335 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) + rhs);
}
| LongDouble& ACE_CDR::LongDouble::operator-- | ( | void | ) | [inline] |
Definition at line 344 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) - 1);
}
| LongDouble ACE_CDR::LongDouble::operator-- | ( | int | ) | [inline] |
Definition at line 352 of file CDR_Base.h.
{
LongDouble ldv = *this;
this->assign (static_cast<NativeImpl> (*this) - 1);
return ldv;
}
| LongDouble& ACE_CDR::LongDouble::operator-= | ( | const NativeImpl | rhs | ) | [inline] |
Definition at line 338 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) - rhs);
}
| LongDouble& ACE_CDR::LongDouble::operator/= | ( | const NativeImpl | rhs | ) | [inline] |
Definition at line 332 of file CDR_Base.h.
{
return this->assign (static_cast<NativeImpl> (*this) / rhs);
}
| bool ACE_CDR::LongDouble::operator== | ( | const LongDouble & | rhs | ) | const |
Definition at line 690 of file CDR_Base.cpp.
{
return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0;
}
| char ACE_CDR::LongDouble::ld[16] |
Definition at line 321 of file CDR_Base.h.
1.7.0