1 /*************************************************************************
3 * $Id: trionan.c 3790 2008-09-01 13:08:57Z veillard $
5 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
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
9 * copyright notice and this permission notice appear in all copies.
11 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
16 ************************************************************************
18 * Functions to handle special quantities in floating-point numbers
19 * (that is, NaNs and infinity). They provide the capability to detect
20 * and fabricate special quantities.
22 * Although written to be as portable as possible, it can never be
23 * guaranteed to work on all platforms, as not all hardware supports
26 * The approach used here (approximately) is to:
28 * 1. Use C99 functionality when available.
29 * 2. Use IEEE 754 bit-patterns if possible.
30 * 3. Use platform-specific techniques.
32 ************************************************************************/
36 * o Put all the magic into trio_fpclassify_and_signbit(), and use this from
40 /*************************************************************************
50 #if defined(TRIO_PLATFORM_UNIX)
53 #if defined(TRIO_COMPILER_DECC)
54 # if defined(__linux__)
57 # include <fp_class.h>
60 /* Small ReactOS hack */
61 #define fpclassify _fpclass
64 #if defined(TRIO_DOCUMENTATION)
65 # include "doc/doc_nan.h"
67 /** @addtogroup SpecialQuantities
71 /*************************************************************************
75 #define TRIO_TRUE (1 == 1)
76 #define TRIO_FALSE (0 == 1)
79 * We must enable IEEE floating-point on Alpha
81 #if defined(__alpha) && !defined(_IEEE_FP)
82 # if defined(TRIO_COMPILER_DECC)
83 # if defined(TRIO_PLATFORM_VMS)
84 # error "Must be compiled with option /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE"
87 # error "Must be compiled with option -ieee"
90 # elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__))
91 # error "Must be compiled with option -mieee"
93 #endif /* __alpha && ! _IEEE_FP */
96 * In ANSI/IEEE 754-1985 64-bits double format numbers have the
97 * following properties (amoungst others)
99 * o FLT_RADIX == 2: binary encoding
100 * o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used
101 * to indicate special numbers (e.g. NaN and Infinity), so the
102 * maximum exponent is 10 bits wide (2^10 == 1024).
103 * o DBL_MANT_DIG == 53: The mantissa is 52 bits wide, but because
104 * numbers are normalized the initial binary 1 is represented
105 * implicitly (the so-called "hidden bit"), which leaves us with
106 * the ability to represent 53 bits wide mantissa.
108 #if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53)
109 # define USE_IEEE_754
113 /*************************************************************************
117 static TRIO_CONST
char rcsid
[] = "@(#)$Id: trionan.c 3790 2008-09-01 13:08:57Z veillard $";
119 #if defined(USE_IEEE_754)
122 * Endian-agnostic indexing macro.
124 * The value of internalEndianMagic, when converted into a 64-bit
125 * integer, becomes 0x0706050403020100 (we could have used a 64-bit
126 * integer value instead of a double, but not all platforms supports
127 * that type). The value is automatically encoded with the correct
128 * endianess by the compiler, which means that we can support any
129 * kind of endianess. The individual bytes are then used as an index
130 * for the IEEE 754 bit-patterns and masks.
132 #define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])
134 #if (defined(__BORLANDC__) && __BORLANDC__ >= 0x0590)
135 static TRIO_CONST
double internalEndianMagic
= 7.949928895127362e-275;
137 static TRIO_CONST
double internalEndianMagic
= 7.949928895127363e-275;
140 /* Mask for the exponent */
141 static TRIO_CONST
unsigned char ieee_754_exponent_mask
[] = {
142 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
145 /* Mask for the mantissa */
146 static TRIO_CONST
unsigned char ieee_754_mantissa_mask
[] = {
147 0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
150 /* Mask for the sign bit */
151 static TRIO_CONST
unsigned char ieee_754_sign_mask
[] = {
152 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
155 /* Bit-pattern for negative zero */
156 static TRIO_CONST
unsigned char ieee_754_negzero_array
[] = {
157 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
160 /* Bit-pattern for infinity */
161 static TRIO_CONST
unsigned char ieee_754_infinity_array
[] = {
162 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
165 /* Bit-pattern for quiet NaN */
166 static TRIO_CONST
unsigned char ieee_754_qnan_array
[] = {
167 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
171 /*************************************************************************
181 TRIO_CONST
unsigned char *values
)
183 TRIO_VOLATILE
double result
;
186 for (i
= 0; i
< (int)sizeof(double); i
++) {
187 ((TRIO_VOLATILE
unsigned char *)&result
)[TRIO_DOUBLE_INDEX(i
)] = values
[i
];
193 * trio_is_special_quantity
196 trio_is_special_quantity
197 TRIO_ARGS2((number
, has_mantissa
),
202 unsigned char current
;
203 int is_special_quantity
= TRIO_TRUE
;
207 for (i
= 0; i
< (unsigned int)sizeof(double); i
++) {
208 current
= ((unsigned char *)&number
)[TRIO_DOUBLE_INDEX(i
)];
210 &= ((current
& ieee_754_exponent_mask
[i
]) == ieee_754_exponent_mask
[i
]);
211 *has_mantissa
|= (current
& ieee_754_mantissa_mask
[i
]);
213 return is_special_quantity
;
225 int is_negative
= TRIO_FALSE
;
227 for (i
= 0; i
< (unsigned int)sizeof(double); i
++) {
228 is_negative
|= (((unsigned char *)&number
)[TRIO_DOUBLE_INDEX(i
)]
229 & ieee_754_sign_mask
[i
]);
234 #endif /* USE_IEEE_754 */
238 Generate negative zero.
240 @return Floating-point representation of negative zero.
243 trio_nzero(TRIO_NOARGS
)
245 #if defined(USE_IEEE_754)
246 return trio_make_double(ieee_754_negzero_array
);
248 TRIO_VOLATILE
double zero
= 0.0;
255 Generate positive infinity.
257 @return Floating-point representation of positive infinity.
260 trio_pinf(TRIO_NOARGS
)
262 /* Cache the result */
263 static double result
= 0.0;
267 #if defined(INFINITY) && defined(__STDC_IEC_559__)
268 result
= (double)INFINITY
;
270 #elif defined(USE_IEEE_754)
271 result
= trio_make_double(ieee_754_infinity_array
);
275 * If HUGE_VAL is different from DBL_MAX, then HUGE_VAL is used
276 * as infinity. Otherwise we have to resort to an overflow
277 * operation to generate infinity.
279 # if defined(TRIO_PLATFORM_UNIX)
280 void (*signal_handler
)(int) = signal(SIGFPE
, SIG_IGN
);
284 if (HUGE_VAL
== DBL_MAX
) {
289 # if defined(TRIO_PLATFORM_UNIX)
290 signal(SIGFPE
, signal_handler
);
299 Generate negative infinity.
301 @return Floating-point value of negative infinity.
304 trio_ninf(TRIO_NOARGS
)
306 static double result
= 0.0;
310 * Negative infinity is calculated by negating positive infinity,
311 * which can be done because it is legal to do calculations on
312 * infinity (for example, 1 / infinity == 0).
314 result
= -trio_pinf();
322 @return Floating-point representation of NaN.
325 trio_nan(TRIO_NOARGS
)
327 /* Cache the result */
328 static double result
= 0.0;
332 #if defined(TRIO_COMPILER_SUPPORTS_C99)
335 #elif defined(NAN) && defined(__STDC_IEC_559__)
336 result
= (double)NAN
;
338 #elif defined(USE_IEEE_754)
339 result
= trio_make_double(ieee_754_qnan_array
);
343 * There are several ways to generate NaN. The one used here is
344 * to divide infinity by infinity. I would have preferred to add
345 * negative infinity to positive infinity, but that yields wrong
346 * result (infinity) on FreeBSD.
348 * This may fail if the hardware does not support NaN, or if
349 * the Invalid Operation floating-point exception is unmasked.
351 # if defined(TRIO_PLATFORM_UNIX)
352 void (*signal_handler
)(int) = signal(SIGFPE
, SIG_IGN
);
355 result
= trio_pinf() / trio_pinf();
357 # if defined(TRIO_PLATFORM_UNIX)
358 signal(SIGFPE
, signal_handler
);
369 @param number An arbitrary floating-point number.
370 @return Boolean value indicating whether or not the number is a NaN.
377 #if (defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isnan)) \
378 || defined(TRIO_COMPILER_SUPPORTS_UNIX95)
380 * C99 defines isnan() as a macro. UNIX95 defines isnan() as a
381 * function. This function was already present in XPG4, but this
382 * is a bit tricky to detect with compiler defines, so we choose
383 * the conservative approach and only use it for UNIX95.
385 return isnan(number
);
387 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
389 * Microsoft Visual C++ and Borland C++ Builder have an _isnan()
392 return _isnan(number
) ? TRIO_TRUE
: TRIO_FALSE
;
394 #elif defined(USE_IEEE_754)
396 * Examine IEEE 754 bit-pattern. A NaN must have a special exponent
397 * pattern, and a non-empty mantissa.
400 int is_special_quantity
;
402 is_special_quantity
= trio_is_special_quantity(number
, &has_mantissa
);
404 return (is_special_quantity
&& has_mantissa
);
411 double integral
, fraction
;
413 # if defined(TRIO_PLATFORM_UNIX)
414 void (*signal_handler
)(int) = signal(SIGFPE
, SIG_IGN
);
418 * NaN is the only number which does not compare to itself
420 ((TRIO_VOLATILE
double)number
!= (TRIO_VOLATILE
double)number
) ||
422 * Fallback solution if NaN compares to NaN
425 (fraction
= modf(number
, &integral
),
426 integral
== fraction
)));
428 # if defined(TRIO_PLATFORM_UNIX)
429 signal(SIGFPE
, signal_handler
);
440 @param number An arbitrary floating-point number.
441 @return 1 if positive infinity, -1 if negative infinity, 0 otherwise.
448 #if defined(TRIO_COMPILER_DECC) && !defined(__linux__)
450 * DECC has an isinf() macro, but it works differently than that
451 * of C99, so we use the fp_class() function instead.
453 return ((fp_class(number
) == FP_POS_INF
)
455 : ((fp_class(number
) == FP_NEG_INF
) ? -1 : 0));
459 * C99 defines isinf() as a macro.
462 ? ((number
> 0.0) ? 1 : -1)
465 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
467 * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
468 * function that can be used to detect infinity.
470 return ((_fpclass(number
) == _FPCLASS_PINF
)
472 : ((_fpclass(number
) == _FPCLASS_NINF
) ? -1 : 0));
474 #elif defined(USE_IEEE_754)
476 * Examine IEEE 754 bit-pattern. Infinity must have a special exponent
477 * pattern, and an empty mantissa.
480 int is_special_quantity
;
482 is_special_quantity
= trio_is_special_quantity(number
, &has_mantissa
);
484 return (is_special_quantity
&& !has_mantissa
)
485 ? ((number
< 0.0) ? -1 : 1)
494 # if defined(TRIO_PLATFORM_UNIX)
495 void (*signal_handler
)(int) = signal(SIGFPE
, SIG_IGN
);
498 double infinity
= trio_pinf();
500 status
= ((number
== infinity
)
502 : ((number
== -infinity
) ? -1 : 0));
504 # if defined(TRIO_PLATFORM_UNIX)
505 signal(SIGFPE
, signal_handler
);
514 /* Temporary fix - this routine is not used anywhere */
518 @param number An arbitrary floating-point number.
519 @return Boolean value indicating whether or not the number is a finite.
526 #if defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isfinite)
528 * C99 defines isfinite() as a macro.
530 return isfinite(number
);
532 #elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
534 * Microsoft Visual C++ and Borland C++ Builder use _finite().
536 return _finite(number
);
538 #elif defined(USE_IEEE_754)
540 * Examine IEEE 754 bit-pattern. For finity we do not care about the
545 return (! trio_is_special_quantity(number
, &dummy
));
551 return ((trio_isinf(number
) == 0) && (trio_isnan(number
) == 0));
559 * The sign of NaN is always false
562 trio_fpclassify_and_signbit
563 TRIO_ARGS2((number
, is_negative
),
567 #if defined(fpclassify) && defined(signbit)
569 * C99 defines fpclassify() and signbit() as a macros
571 *is_negative
= signbit(number
);
572 switch (fpclassify(number
)) {
576 return TRIO_FP_INFINITE
;
578 return TRIO_FP_SUBNORMAL
;
582 return TRIO_FP_NORMAL
;
586 # if defined(TRIO_COMPILER_DECC)
588 * DECC has an fp_class() function.
590 # define TRIO_FPCLASSIFY(n) fp_class(n)
591 # define TRIO_QUIET_NAN FP_QNAN
592 # define TRIO_SIGNALLING_NAN FP_SNAN
593 # define TRIO_POSITIVE_INFINITY FP_POS_INF
594 # define TRIO_NEGATIVE_INFINITY FP_NEG_INF
595 # define TRIO_POSITIVE_SUBNORMAL FP_POS_DENORM
596 # define TRIO_NEGATIVE_SUBNORMAL FP_NEG_DENORM
597 # define TRIO_POSITIVE_ZERO FP_POS_ZERO
598 # define TRIO_NEGATIVE_ZERO FP_NEG_ZERO
599 # define TRIO_POSITIVE_NORMAL FP_POS_NORM
600 # define TRIO_NEGATIVE_NORMAL FP_NEG_NORM
602 # elif defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
604 * Microsoft Visual C++ and Borland C++ Builder have an _fpclass()
607 # define TRIO_FPCLASSIFY(n) _fpclass(n)
608 # define TRIO_QUIET_NAN _FPCLASS_QNAN
609 # define TRIO_SIGNALLING_NAN _FPCLASS_SNAN
610 # define TRIO_POSITIVE_INFINITY _FPCLASS_PINF
611 # define TRIO_NEGATIVE_INFINITY _FPCLASS_NINF
612 # define TRIO_POSITIVE_SUBNORMAL _FPCLASS_PD
613 # define TRIO_NEGATIVE_SUBNORMAL _FPCLASS_ND
614 # define TRIO_POSITIVE_ZERO _FPCLASS_PZ
615 # define TRIO_NEGATIVE_ZERO _FPCLASS_NZ
616 # define TRIO_POSITIVE_NORMAL _FPCLASS_PN
617 # define TRIO_NEGATIVE_NORMAL _FPCLASS_NN
619 # elif defined(FP_PLUS_NORM)
621 * HP-UX 9.x and 10.x have an fpclassify() function, that is different
622 * from the C99 fpclassify() macro supported on HP-UX 11.x.
624 * AIX has class() for C, and _class() for C++, which returns the
625 * same values as the HP-UX fpclassify() function.
627 # if defined(TRIO_PLATFORM_AIX)
628 # if defined(__cplusplus)
629 # define TRIO_FPCLASSIFY(n) _class(n)
631 # define TRIO_FPCLASSIFY(n) class(n)
634 # define TRIO_FPCLASSIFY(n) fpclassify(n)
636 # define TRIO_QUIET_NAN FP_QNAN
637 # define TRIO_SIGNALLING_NAN FP_SNAN
638 # define TRIO_POSITIVE_INFINITY FP_PLUS_INF
639 # define TRIO_NEGATIVE_INFINITY FP_MINUS_INF
640 # define TRIO_POSITIVE_SUBNORMAL FP_PLUS_DENORM
641 # define TRIO_NEGATIVE_SUBNORMAL FP_MINUS_DENORM
642 # define TRIO_POSITIVE_ZERO FP_PLUS_ZERO
643 # define TRIO_NEGATIVE_ZERO FP_MINUS_ZERO
644 # define TRIO_POSITIVE_NORMAL FP_PLUS_NORM
645 # define TRIO_NEGATIVE_NORMAL FP_MINUS_NORM
648 # if defined(TRIO_FPCLASSIFY)
649 switch (TRIO_FPCLASSIFY(number
)) {
651 case TRIO_SIGNALLING_NAN
:
652 *is_negative
= TRIO_FALSE
; /* NaN has no sign */
654 case TRIO_POSITIVE_INFINITY
:
655 *is_negative
= TRIO_FALSE
;
656 return TRIO_FP_INFINITE
;
657 case TRIO_NEGATIVE_INFINITY
:
658 *is_negative
= TRIO_TRUE
;
659 return TRIO_FP_INFINITE
;
660 case TRIO_POSITIVE_SUBNORMAL
:
661 *is_negative
= TRIO_FALSE
;
662 return TRIO_FP_SUBNORMAL
;
663 case TRIO_NEGATIVE_SUBNORMAL
:
664 *is_negative
= TRIO_TRUE
;
665 return TRIO_FP_SUBNORMAL
;
666 case TRIO_POSITIVE_ZERO
:
667 *is_negative
= TRIO_FALSE
;
669 case TRIO_NEGATIVE_ZERO
:
670 *is_negative
= TRIO_TRUE
;
672 case TRIO_POSITIVE_NORMAL
:
673 *is_negative
= TRIO_FALSE
;
674 return TRIO_FP_NORMAL
;
675 case TRIO_NEGATIVE_NORMAL
:
676 *is_negative
= TRIO_TRUE
;
677 return TRIO_FP_NORMAL
;
679 /* Just in case... */
680 *is_negative
= (number
< 0.0);
681 return TRIO_FP_NORMAL
;
692 * In IEEE 754 the sign of zero is ignored in comparisons, so we
693 * have to handle this as a special case by examining the sign bit
696 # if defined(USE_IEEE_754)
697 *is_negative
= trio_is_negative(number
);
699 *is_negative
= TRIO_FALSE
; /* FIXME */
703 if (trio_isnan(number
)) {
704 *is_negative
= TRIO_FALSE
;
707 if ((rc
= trio_isinf(number
))) {
708 *is_negative
= (rc
== -1);
709 return TRIO_FP_INFINITE
;
711 if ((number
> 0.0) && (number
< DBL_MIN
)) {
712 *is_negative
= TRIO_FALSE
;
713 return TRIO_FP_SUBNORMAL
;
715 if ((number
< 0.0) && (number
> -DBL_MIN
)) {
716 *is_negative
= TRIO_TRUE
;
717 return TRIO_FP_SUBNORMAL
;
719 *is_negative
= (number
< 0.0);
720 return TRIO_FP_NORMAL
;
727 Examine the sign of a number.
729 @param number An arbitrary floating-point number.
730 @return Boolean value indicating whether or not the number has the
731 sign bit set (i.e. is negative).
740 (void)trio_fpclassify_and_signbit(number
, &is_negative
);
745 /* Temporary fix - this routine is not used in libxml */
747 Examine the class of a number.
749 @param number An arbitrary floating-point number.
750 @return Enumerable value indicating the class of @p number
759 return trio_fpclassify_and_signbit(number
, &dummy
);
764 /** @} SpecialQuantities */
766 /*************************************************************************
769 * Add the following compiler option to include this test code.
771 * Unix : -DSTANDALONE
772 * VMS : /DEFINE=(STANDALONE)
774 #if defined(STANDALONE)
777 static TRIO_CONST
char *
783 case TRIO_FP_INFINITE
:
784 return "FP_INFINITE";
789 case TRIO_FP_SUBNORMAL
:
790 return "FP_SUBNORMAL";
800 TRIO_ARGS2((prefix
, number
),
801 TRIO_CONST
char *prefix
,
804 printf("%-6s: %s %-15s %g\n",
806 trio_signbit(number
) ? "-" : "+",
807 getClassification(TRIO_FPCLASSIFY(number
)),
811 int main(TRIO_NOARGS
)
816 # if defined(TRIO_PLATFORM_UNIX)
817 void (*signal_handler
) TRIO_PROTO((int));
821 my_pinf
= trio_pinf();
822 my_ninf
= trio_ninf();
824 print_class("Nan", my_nan
);
825 print_class("PInf", my_pinf
);
826 print_class("NInf", my_ninf
);
827 print_class("PZero", 0.0);
828 print_class("NZero", -0.0);
829 print_class("PNorm", 1.0);
830 print_class("NNorm", -1.0);
831 print_class("PSub", 1.01e-307 - 1.00e-307);
832 print_class("NSub", 1.00e-307 - 1.01e-307);
834 printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
836 ((unsigned char *)&my_nan
)[0],
837 ((unsigned char *)&my_nan
)[1],
838 ((unsigned char *)&my_nan
)[2],
839 ((unsigned char *)&my_nan
)[3],
840 ((unsigned char *)&my_nan
)[4],
841 ((unsigned char *)&my_nan
)[5],
842 ((unsigned char *)&my_nan
)[6],
843 ((unsigned char *)&my_nan
)[7],
844 trio_isnan(my_nan
), trio_isinf(my_nan
));
845 printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
847 ((unsigned char *)&my_pinf
)[0],
848 ((unsigned char *)&my_pinf
)[1],
849 ((unsigned char *)&my_pinf
)[2],
850 ((unsigned char *)&my_pinf
)[3],
851 ((unsigned char *)&my_pinf
)[4],
852 ((unsigned char *)&my_pinf
)[5],
853 ((unsigned char *)&my_pinf
)[6],
854 ((unsigned char *)&my_pinf
)[7],
855 trio_isnan(my_pinf
), trio_isinf(my_pinf
));
856 printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
858 ((unsigned char *)&my_ninf
)[0],
859 ((unsigned char *)&my_ninf
)[1],
860 ((unsigned char *)&my_ninf
)[2],
861 ((unsigned char *)&my_ninf
)[3],
862 ((unsigned char *)&my_ninf
)[4],
863 ((unsigned char *)&my_ninf
)[5],
864 ((unsigned char *)&my_ninf
)[6],
865 ((unsigned char *)&my_ninf
)[7],
866 trio_isnan(my_ninf
), trio_isinf(my_ninf
));
868 # if defined(TRIO_PLATFORM_UNIX)
869 signal_handler
= signal(SIGFPE
, SIG_IGN
);
872 my_pinf
= DBL_MAX
+ DBL_MAX
;
874 my_nan
= my_pinf
/ my_pinf
;
876 # if defined(TRIO_PLATFORM_UNIX)
877 signal(SIGFPE
, signal_handler
);
880 printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
882 ((unsigned char *)&my_nan
)[0],
883 ((unsigned char *)&my_nan
)[1],
884 ((unsigned char *)&my_nan
)[2],
885 ((unsigned char *)&my_nan
)[3],
886 ((unsigned char *)&my_nan
)[4],
887 ((unsigned char *)&my_nan
)[5],
888 ((unsigned char *)&my_nan
)[6],
889 ((unsigned char *)&my_nan
)[7],
890 trio_isnan(my_nan
), trio_isinf(my_nan
));
891 printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
893 ((unsigned char *)&my_pinf
)[0],
894 ((unsigned char *)&my_pinf
)[1],
895 ((unsigned char *)&my_pinf
)[2],
896 ((unsigned char *)&my_pinf
)[3],
897 ((unsigned char *)&my_pinf
)[4],
898 ((unsigned char *)&my_pinf
)[5],
899 ((unsigned char *)&my_pinf
)[6],
900 ((unsigned char *)&my_pinf
)[7],
901 trio_isnan(my_pinf
), trio_isinf(my_pinf
));
902 printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
904 ((unsigned char *)&my_ninf
)[0],
905 ((unsigned char *)&my_ninf
)[1],
906 ((unsigned char *)&my_ninf
)[2],
907 ((unsigned char *)&my_ninf
)[3],
908 ((unsigned char *)&my_ninf
)[4],
909 ((unsigned char *)&my_ninf
)[5],
910 ((unsigned char *)&my_ninf
)[6],
911 ((unsigned char *)&my_ninf
)[7],
912 trio_isnan(my_ninf
), trio_isinf(my_ninf
));