#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 287 of file CDR_Base.h. Referenced by assign(), operator *=(), operator NativeImpl(), operator+=(), operator-=(), and operator/=(). |
|
|
Definition at line 679 of file CDR_Base.cpp.
00680 {
00681 if (this != &rhs)
00682 *this = rhs;
00683 return *this;
00684 }
|
|
|
Definition at line 608 of file CDR_Base.cpp. References ld, max_eleven_bit, max_fifteen_bit, ACE_OS::memcpy(), ACE_OS::memset(), NativeImpl, ACE_CDR::swap_16(), and ACE_CDR::swap_8(). Referenced by operator NativeImpl().
00609 {
00610 ACE_OS::memset (this->ld, 0, sizeof (this->ld));
00611
00612 if (sizeof (rhs) == 8)
00613 {
00614 #if defined (ACE_LITTLE_ENDIAN)
00615 static const size_t byte_zero = 1;
00616 static const size_t byte_one = 0;
00617 char rhs_ptr[16];
00618 ACE_CDR::swap_8 (reinterpret_cast<const char*> (&rhs), rhs_ptr);
00619 #else
00620 static const size_t byte_zero = 0;
00621 static const size_t byte_one = 1;
00622 const char* rhs_ptr = reinterpret_cast<const char*> (&rhs);
00623 #endif
00624 ACE_INT16 sign = static_cast<ACE_INT16> (
00625 static_cast<signed char> (rhs_ptr[0])) & 0x8000;
00626 ACE_INT16 exponent = ((rhs_ptr[0] & 0x7f) << 4) |
00627 ((rhs_ptr[1] >> 4) & 0xf);
00628 const char* exp_ptr = reinterpret_cast<const char*> (&exponent);
00629
00630 // Infinity and NaN have an exponent of 0x7ff in 64-bit IEEE
00631 if (exponent == 0x7ff)
00632 {
00633 exponent = 0x7fff;
00634 }
00635 else
00636 {
00637 exponent = (exponent - max_eleven_bit) + max_fifteen_bit;
00638 }
00639 exponent |= sign;
00640
00641 // Store the sign bit and exponent
00642 this->ld[0] = exp_ptr[byte_zero];
00643 this->ld[1] = exp_ptr[byte_one];
00644
00645 // Store the mantissa. In an 8 byte double, it is split by
00646 // 4 bits (because of the 12 bits for sign and exponent), so
00647 // we have to shift and or the rhs to get the right bytes.
00648 size_t li = 2;
00649 bool direction = true;
00650 for (size_t ri = 1; ri < sizeof (rhs);)
00651 {
00652 if (direction)
00653 {
00654 this->ld[li] |= ((rhs_ptr[ri] << 4) & 0xf0);
00655 direction = false;
00656 ++ri;
00657 }
00658 else
00659 {
00660 this->ld[li] |= ((rhs_ptr[ri] >> 4) & 0xf);
00661 direction = true;
00662 ++li;
00663 }
00664 }
00665 #if defined (ACE_LITTLE_ENDIAN)
00666 ACE_OS::memcpy (rhs_ptr, this->ld, sizeof (this->ld));
00667 ACE_CDR::swap_16 (rhs_ptr, this->ld);
00668 #endif
00669 }
00670 else
00671 {
00672 ACE_OS::memcpy(this->ld,
00673 reinterpret_cast<const char*> (&rhs), sizeof (rhs));
00674 }
00675 return *this;
00676 }
|
|
|
Definition at line 300 of file CDR_Base.h. References NativeImpl.
00300 {
00301 return this->assign (static_cast<NativeImpl> (*this) * rhs);
00302 }
|
|
|
Definition at line 698 of file CDR_Base.cpp. References assign(), ld, max_eleven_bit, max_fifteen_bit, ACE_OS::memcpy(), NativeImpl, ACE_CDR::swap_16(), and ACE_CDR::swap_8().
00699 {
00700 ACE_CDR::LongDouble::NativeImpl ret = 0.0;
00701 char* lhs_ptr = reinterpret_cast<char*> (&ret);
00702
00703 if (sizeof (ret) == 8)
00704 {
00705 #if defined (ACE_LITTLE_ENDIAN)
00706 static const size_t byte_zero = 1;
00707 static const size_t byte_one = 0;
00708 char copy[16];
00709 ACE_CDR::swap_16 (this->ld, copy);
00710 #else
00711 static const size_t byte_zero = 0;
00712 static const size_t byte_one = 1;
00713 const char* copy = this->ld;
00714 #endif
00715 ACE_INT16 exponent = 0;
00716 char* exp_ptr = reinterpret_cast<char*> (&exponent);
00717 exp_ptr[byte_zero] = copy[0];
00718 exp_ptr[byte_one] = copy[1];
00719
00720 ACE_INT16 sign = (exponent & 0x8000);
00721 exponent &= 0x7fff;
00722
00723 // Infinity and NaN have an exponent of 0x7fff in 128-bit IEEE
00724 if (exponent == 0x7fff)
00725 {
00726 exponent = 0x7ff;
00727 }
00728 else
00729 {
00730 exponent = (exponent - max_fifteen_bit) + max_eleven_bit;
00731 }
00732 exponent = (exponent << 4) | sign;
00733
00734 // Store the sign and exponent
00735 lhs_ptr[0] = exp_ptr[byte_zero];
00736 lhs_ptr[1] = exp_ptr[byte_one];
00737
00738 // Store the mantissa. In an 8 byte double, it is split by
00739 // 4 bits (because of the 12 bits for sign and exponent), so
00740 // we have to shift and or the rhs to get the right bytes.
00741 size_t li = 1;
00742 bool direction = true;
00743 for (size_t ri = 2; li < sizeof (ret);) {
00744 if (direction)
00745 {
00746 lhs_ptr[li] |= ((copy[ri] >> 4) & 0xf);
00747 direction = false;
00748 ++li;
00749 }
00750 else
00751 {
00752 lhs_ptr[li] |= ((copy[ri] & 0xf) << 4);
00753 direction = true;
00754 ++ri;
00755 }
00756 }
00757
00758 #if defined (ACE_LITTLE_ENDIAN)
00759 ACE_CDR::swap_8 (lhs_ptr, lhs_ptr);
00760 #endif
00761 }
00762 else
00763 {
00764 ACE_OS::memcpy(lhs_ptr, this->ld, sizeof (ret));
00765 }
00766
00767 // This bit of code is unnecessary. However, this code is
00768 // necessary to work around a bug in the gcc 4.1.1 optimizer.
00769 ACE_CDR::LongDouble tmp;
00770 tmp.assign (ret);
00771
00772 return ret;
00773 }
|
|
|
Definition at line 693 of file CDR_Base.cpp. References ld, and ACE_OS::memcmp().
00694 {
00695 return ACE_OS::memcmp (this->ld, rhs.ld, 16) != 0;
00696 }
|
|
|
Definition at line 318 of file CDR_Base.h.
00318 {
00319 LongDouble ldv = *this;
00320 this->assign (static_cast<NativeImpl> (*this) + 1);
00321 return ldv;
00322 }
|
|
|
Definition at line 312 of file CDR_Base.h.
00312 {
00313 return this->assign (static_cast<NativeImpl> (*this) + 1);
00314 }
|
|
|
Definition at line 306 of file CDR_Base.h. References NativeImpl.
00306 {
00307 return this->assign (static_cast<NativeImpl> (*this) + rhs);
00308 }
|
|
|
Definition at line 323 of file CDR_Base.h.
00323 {
00324 LongDouble ldv = *this;
00325 this->assign (static_cast<NativeImpl> (*this) - 1);
00326 return ldv;
00327 }
|
|
|
Definition at line 315 of file CDR_Base.h.
00315 {
00316 return this->assign (static_cast<NativeImpl> (*this) - 1);
00317 }
|
|
|
Definition at line 309 of file CDR_Base.h. References NativeImpl.
00309 {
00310 return this->assign (static_cast<NativeImpl> (*this) - rhs);
00311 }
|
|
|
Definition at line 303 of file CDR_Base.h. References NativeImpl.
00303 {
00304 return this->assign (static_cast<NativeImpl> (*this) / rhs);
00305 }
|
|
|
Definition at line 687 of file CDR_Base.cpp. References ld, and ACE_OS::memcmp().
00688 {
00689 return ACE_OS::memcmp (this->ld, rhs.ld, 16) == 0;
00690 }
|
|
|
Definition at line 292 of file CDR_Base.h. Referenced by assign(), operator NativeImpl(), operator!=(), and operator==(). |
1.3.6