| OLD | NEW |
| 1 /************************************************************************* | 1 /************************************************************************* |
| 2 * | 2 * |
| 3 * $Id: trionan.c 2219 2003-10-15 08:18:00Z veillard $ | 3 * $Id$ |
| 4 * | 4 * |
| 5 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net> | 5 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net> |
| 6 * | 6 * |
| 7 * Permission to use, copy, modify, and distribute this software for any | 7 * Permission to use, copy, modify, and distribute this software for any |
| 8 * purpose with or without fee is hereby granted, provided that the above | 8 * purpose with or without fee is hereby granted, provided that the above |
| 9 * copyright notice and this permission notice appear in all copies. | 9 * copyright notice and this permission notice appear in all copies. |
| 10 * | 10 * |
| 11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | 11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
| 12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | 12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND | 13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 */ | 105 */ |
| 106 #if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53) | 106 #if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53) |
| 107 # define USE_IEEE_754 | 107 # define USE_IEEE_754 |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 | 110 |
| 111 /************************************************************************* | 111 /************************************************************************* |
| 112 * Constants | 112 * Constants |
| 113 */ | 113 */ |
| 114 | 114 |
| 115 static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c 2219 2003-10-15 08:18:00Z v
eillard $"; | 115 static TRIO_CONST char rcsid[] = "@(#)$Id$"; |
| 116 | 116 |
| 117 #if defined(USE_IEEE_754) | 117 #if defined(USE_IEEE_754) |
| 118 | 118 |
| 119 /* | 119 /* |
| 120 * Endian-agnostic indexing macro. | 120 * Endian-agnostic indexing macro. |
| 121 * | 121 * |
| 122 * The value of internalEndianMagic, when converted into a 64-bit | 122 * The value of internalEndianMagic, when converted into a 64-bit |
| 123 * integer, becomes 0x0706050403020100 (we could have used a 64-bit | 123 * integer, becomes 0x0706050403020100 (we could have used a 64-bit |
| 124 * integer value instead of a double, but not all platforms supports | 124 * integer value instead of a double, but not all platforms supports |
| 125 * that type). The value is automatically encoded with the correct | 125 * that type). The value is automatically encoded with the correct |
| 126 * endianess by the compiler, which means that we can support any | 126 * endianess by the compiler, which means that we can support any |
| 127 * kind of endianess. The individual bytes are then used as an index | 127 * kind of endianess. The individual bytes are then used as an index |
| 128 * for the IEEE 754 bit-patterns and masks. | 128 * for the IEEE 754 bit-patterns and masks. |
| 129 */ | 129 */ |
| 130 #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) | 130 #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)]) |
| 131 | 131 |
| 132 #if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0590) |
| 133 static TRIO_CONST double internalEndianMagic = 7.949928895127362e-275; |
| 134 #else |
| 132 static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; | 135 static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275; |
| 136 #endif |
| 133 | 137 |
| 134 /* Mask for the exponent */ | 138 /* Mask for the exponent */ |
| 135 static TRIO_CONST unsigned char ieee_754_exponent_mask[] = { | 139 static TRIO_CONST unsigned char ieee_754_exponent_mask[] = { |
| 136 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 140 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 137 }; | 141 }; |
| 138 | 142 |
| 139 /* Mask for the mantissa */ | 143 /* Mask for the mantissa */ |
| 140 static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = { | 144 static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = { |
| 141 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF | 145 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF |
| 142 }; | 146 }; |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 ((unsigned char *)&my_ninf)[3], | 905 ((unsigned char *)&my_ninf)[3], |
| 902 ((unsigned char *)&my_ninf)[4], | 906 ((unsigned char *)&my_ninf)[4], |
| 903 ((unsigned char *)&my_ninf)[5], | 907 ((unsigned char *)&my_ninf)[5], |
| 904 ((unsigned char *)&my_ninf)[6], | 908 ((unsigned char *)&my_ninf)[6], |
| 905 ((unsigned char *)&my_ninf)[7], | 909 ((unsigned char *)&my_ninf)[7], |
| 906 trio_isnan(my_ninf), trio_isinf(my_ninf)); | 910 trio_isnan(my_ninf), trio_isinf(my_ninf)); |
| 907 | 911 |
| 908 return 0; | 912 return 0; |
| 909 } | 913 } |
| 910 #endif | 914 #endif |
| OLD | NEW |