123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- /**
- @file
- @ingroup epd
- @brief Internal header for the University of Colorado extended
- double precision package.
- @author In-Ho Moon
- @copyright@parblock
- Copyright (c) 1995-2015, Regents of the University of Colorado
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- Neither the name of the University of Colorado nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- @endparblock
- */
- #ifndef EPD_INT_H_
- #define EPD_INT_H_
- #include "config.h"
- #include "epd.h"
- #if WORDS_BIGENDIAN == 1
- #define EPD_BIG_ENDIAN
- #endif
- /*---------------------------------------------------------------------------*/
- /* Constant declarations */
- /*---------------------------------------------------------------------------*/
- #define EPD_MAX_BIN 1023
- #define EPD_MAX_DEC 308
- #define EPD_EXP_INF 0x7ff
- /*---------------------------------------------------------------------------*/
- /* Type declarations */
- /*---------------------------------------------------------------------------*/
- typedef struct IeeeDoubleStruct IeeeDouble;
- typedef struct IeeeNanStruct IeeeNan;
- typedef union EpTypeUnion EpType;
- /*---------------------------------------------------------------------------*/
- /* Structure declarations */
- /*---------------------------------------------------------------------------*/
- /**
- @brief IEEE double struct.
- */
- #ifdef EPD_BIG_ENDIAN
- struct IeeeDoubleStruct { /* BIG_ENDIAN */
- unsigned int sign: 1;
- unsigned int exponent: 11;
- unsigned int mantissa0: 20;
- unsigned int mantissa1: 32;
- };
- #else
- struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
- unsigned int mantissa1: 32;
- unsigned int mantissa0: 20;
- unsigned int exponent: 11;
- unsigned int sign: 1;
- };
- #endif
- /**
- @brief IEEE double NaN struct.
- */
- #ifdef EPD_BIG_ENDIAN
- struct IeeeNanStruct { /* BIG_ENDIAN */
- unsigned int sign: 1;
- unsigned int exponent: 11;
- unsigned int quiet_bit: 1;
- unsigned int mantissa0: 19;
- unsigned int mantissa1: 32;
- };
- #else
- struct IeeeNanStruct { /* LITTLE_ENDIAN */
- unsigned int mantissa1: 32;
- unsigned int mantissa0: 19;
- unsigned int quiet_bit: 1;
- unsigned int exponent: 11;
- unsigned int sign: 1;
- };
- #endif
- /**
- @brief Different views of a double.
- */
- union EpTypeUnion {
- double value;
- struct IeeeDoubleStruct bits;
- struct IeeeNanStruct nan;
- };
- /**
- @brief Extended precision double to keep very large value.
- */
- struct EpDoubleStruct {
- union EpTypeUnion type;
- int exponent;
- };
- /*---------------------------------------------------------------------------*/
- /* Function prototypes */
- /*---------------------------------------------------------------------------*/
- #ifdef __cplusplus
- extern "C" {
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif /* EPD_H_ */
|