Blame trio/trionan.c

Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 *
Packit Service a2489d
 * $Id: trionan.c,v 1.20 2002/06/30 10:20:30 breese Exp $
Packit Service a2489d
 *
Packit Service a2489d
 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
Packit Service a2489d
 *
Packit Service a2489d
 * Permission to use, copy, modify, and distribute this software for any
Packit Service a2489d
 * purpose with or without fee is hereby granted, provided that the above
Packit Service a2489d
 * copyright notice and this permission notice appear in all copies.
Packit Service a2489d
 *
Packit Service a2489d
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
Packit Service a2489d
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
Packit Service a2489d
 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
Packit Service a2489d
 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
Packit Service a2489d
 *
Packit Service a2489d
 ************************************************************************
Packit Service a2489d
 *
Packit Service a2489d
 * Functions to handle special quantities in floating-point numbers
Packit Service a2489d
 * (that is, NaNs and infinity). They provide the capability to detect
Packit Service a2489d
 * and fabricate special quantities.
Packit Service a2489d
 *
Packit Service a2489d
 * Although written to be as portable as possible, it can never be
Packit Service a2489d
 * guaranteed to work on all platforms, as not all hardware supports
Packit Service a2489d
 * special quantities.
Packit Service a2489d
 *
Packit Service a2489d
 * The approach used here (approximately) is to:
Packit Service a2489d
 *
Packit Service a2489d
 *   1. Use C99 functionality when available.
Packit Service a2489d
 *   2. Use IEEE 754 bit-patterns if possible.
Packit Service a2489d
 *   3. Use platform-specific techniques.
Packit Service a2489d
 *
Packit Service a2489d
 ************************************************************************/
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * TODO:
Packit Service a2489d
 *  o Put all the magic into trio_fpclassify_and_signbit(), and use this from
Packit Service a2489d
 *    trio_isnan() etc.
Packit Service a2489d
 */
Packit Service a2489d
Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 * Include files
Packit Service a2489d
 */
Packit Service a2489d
#include "triodef.h"
Packit Service a2489d
#include "trionan.h"
Packit Service a2489d
Packit Service a2489d
#include <math.h>
Packit Service a2489d
#include <string.h>
Packit Service a2489d
#include <limits.h>
Packit Service a2489d
#include <float.h>
Packit Service a2489d
#if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
# include <signal.h>
Packit Service a2489d
#endif
Packit Service a2489d
#if defined(TRIO_COMPILER_DECC)
Packit Service a2489d
# include <fp_class.h>
Packit Service a2489d
#endif
Packit Service a2489d
#include <assert.h>
Packit Service a2489d
Packit Service a2489d
#if defined(TRIO_DOCUMENTATION)
Packit Service a2489d
# include "doc/doc_nan.h"
Packit Service a2489d
#endif
Packit Service a2489d
/** @addtogroup SpecialQuantities
Packit Service a2489d
    @{
Packit Service a2489d
*/
Packit Service a2489d
Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 * Definitions
Packit Service a2489d
 */
Packit Service a2489d
Packit Service a2489d
#define TRIO_TRUE (1 == 1)
Packit Service a2489d
#define TRIO_FALSE (0 == 1)
Packit Service a2489d
Packit Service a2489d
/* We must enable IEEE floating-point on Alpha */
Packit Service a2489d
#if defined(__alpha) && !defined(_IEEE_FP)
Packit Service a2489d
# if defined(TRIO_COMPILER_DECC)
Packit Service a2489d
#  if defined(TRIO_PLATFORM_VMS)
Packit Service a2489d
#   error "Must be compiled with option /IEEE_MODE=UNDERFLOW_TO_ZERO/FLOAT=IEEE"
Packit Service a2489d
#  else
Packit Service a2489d
#   if !defined(_CFE)
Packit Service a2489d
#    error "Must be compiled with option -ieee"
Packit Service a2489d
#   endif
Packit Service a2489d
#  endif
Packit Service a2489d
# elif defined(TRIO_COMPILER_GCC) && (defined(__osf__) || defined(__linux__))
Packit Service a2489d
#  error "Must be compiled with option -mieee"
Packit Service a2489d
# endif
Packit Service a2489d
#endif /* __alpha && ! _IEEE_FP */
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * In ANSI/IEEE 754-1985 64-bits double format numbers have the
Packit Service a2489d
 * following properties (amoungst others)
Packit Service a2489d
 *
Packit Service a2489d
 *   o FLT_RADIX == 2: binary encoding
Packit Service a2489d
 *   o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used
Packit Service a2489d
 *     to indicate special numbers (e.g. NaN and Infinity), so the
Packit Service a2489d
 *     maximum exponent is 10 bits wide (2^10 == 1024).
Packit Service a2489d
 *   o DBL_MANT_DIG == 53: The mantissa is 52 bits wide, but because
Packit Service a2489d
 *     numbers are normalized the initial binary 1 is represented
Packit Service a2489d
 *     implicitly (the so-called "hidden bit"), which leaves us with
Packit Service a2489d
 *     the ability to represent 53 bits wide mantissa.
Packit Service a2489d
 */
Packit Service a2489d
#if (FLT_RADIX == 2) && (DBL_MAX_EXP == 1024) && (DBL_MANT_DIG == 53)
Packit Service a2489d
# define USE_IEEE_754
Packit Service a2489d
#endif
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 * Constants
Packit Service a2489d
 */
Packit Service a2489d
Packit Service a2489d
static TRIO_CONST char rcsid[] = "@(#)$Id: trionan.c,v 1.20 2002/06/30 10:20:30 breese Exp $";
Packit Service a2489d
Packit Service a2489d
#if defined(USE_IEEE_754)
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * Endian-agnostic indexing macro.
Packit Service a2489d
 *
Packit Service a2489d
 * The value of internalEndianMagic, when converted into a 64-bit
Packit Service a2489d
 * integer, becomes 0x0706050403020100 (we could have used a 64-bit
Packit Service a2489d
 * integer value instead of a double, but not all platforms supports
Packit Service a2489d
 * that type). The value is automatically encoded with the correct
Packit Service a2489d
 * endianess by the compiler, which means that we can support any
Packit Service a2489d
 * kind of endianess. The individual bytes are then used as an index
Packit Service a2489d
 * for the IEEE 754 bit-patterns and masks.
Packit Service a2489d
 */
Packit Service a2489d
#define TRIO_DOUBLE_INDEX(x) (((unsigned char *)&internalEndianMagic)[7-(x)])
Packit Service a2489d
Packit Service a2489d
static TRIO_CONST double internalEndianMagic = 7.949928895127363e-275;
Packit Service a2489d
Packit Service a2489d
/* Mask for the exponent */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_exponent_mask[] = {
Packit Service a2489d
  0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
/* Mask for the mantissa */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_mantissa_mask[] = {
Packit Service a2489d
  0x00, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
/* Mask for the sign bit */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_sign_mask[] = {
Packit Service a2489d
  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
/* Bit-pattern for negative zero */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_negzero_array[] = {
Packit Service a2489d
  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
/* Bit-pattern for infinity */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_infinity_array[] = {
Packit Service a2489d
  0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
/* Bit-pattern for quiet NaN */
Packit Service a2489d
static TRIO_CONST unsigned char ieee_754_qnan_array[] = {
Packit Service a2489d
  0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
Packit Service a2489d
};
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 * Functions
Packit Service a2489d
 */
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * trio_make_double
Packit Service a2489d
 */
Packit Service a2489d
TRIO_PRIVATE double
Packit Service a2489d
trio_make_double
Packit Service a2489d
TRIO_ARGS1((values),
Packit Service a2489d
	   TRIO_CONST unsigned char *values)
Packit Service a2489d
{
Packit Service a2489d
  TRIO_VOLATILE double result;
Packit Service a2489d
  int i;
Packit Service a2489d
Packit Service a2489d
  for (i = 0; i < (int)sizeof(double); i++) {
Packit Service a2489d
    ((TRIO_VOLATILE unsigned char *)&result)[TRIO_DOUBLE_INDEX(i)] = values[i];
Packit Service a2489d
  }
Packit Service a2489d
  return result;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * trio_is_special_quantity
Packit Service a2489d
 */
Packit Service a2489d
TRIO_PRIVATE int
Packit Service a2489d
trio_is_special_quantity
Packit Service a2489d
TRIO_ARGS2((number, has_mantissa),
Packit Service a2489d
	   double number,
Packit Service a2489d
	   int *has_mantissa)
Packit Service a2489d
{
Packit Service a2489d
  unsigned int i;
Packit Service a2489d
  unsigned char current;
Packit Service a2489d
  int is_special_quantity = TRIO_TRUE;
Packit Service a2489d
Packit Service a2489d
  *has_mantissa = 0;
Packit Service a2489d
Packit Service a2489d
  for (i = 0; i < (unsigned int)sizeof(double); i++) {
Packit Service a2489d
    current = ((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)];
Packit Service a2489d
    is_special_quantity
Packit Service a2489d
      &= ((current & ieee_754_exponent_mask[i]) == ieee_754_exponent_mask[i]);
Packit Service a2489d
    *has_mantissa |= (current & ieee_754_mantissa_mask[i]);
Packit Service a2489d
  }
Packit Service a2489d
  return is_special_quantity;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * trio_is_negative
Packit Service a2489d
 */
Packit Service a2489d
TRIO_PRIVATE int
Packit Service a2489d
trio_is_negative
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
  unsigned int i;
Packit Service a2489d
  int is_negative = TRIO_FALSE;
Packit Service a2489d
Packit Service a2489d
  for (i = 0; i < (unsigned int)sizeof(double); i++) {
Packit Service a2489d
    is_negative |= (((unsigned char *)&number)[TRIO_DOUBLE_INDEX(i)]
Packit Service a2489d
		    & ieee_754_sign_mask[i]);
Packit Service a2489d
  }
Packit Service a2489d
  return is_negative;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
#endif /* USE_IEEE_754 */
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Generate negative zero.
Packit Service a2489d
Packit Service a2489d
   @return Floating-point representation of negative zero.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC double
Packit Service a2489d
trio_nzero(TRIO_NOARGS)
Packit Service a2489d
{
Packit Service a2489d
#if defined(USE_IEEE_754)
Packit Service a2489d
  return trio_make_double(ieee_754_negzero_array);
Packit Service a2489d
#else
Packit Service a2489d
  TRIO_VOLATILE double zero = 0.0;
Packit Service a2489d
Packit Service a2489d
  return -zero;
Packit Service a2489d
#endif
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Generate positive infinity.
Packit Service a2489d
Packit Service a2489d
   @return Floating-point representation of positive infinity.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC double
Packit Service a2489d
trio_pinf(TRIO_NOARGS)
Packit Service a2489d
{
Packit Service a2489d
  /* Cache the result */
Packit Service a2489d
  static double result = 0.0;
Packit Service a2489d
Packit Service a2489d
  if (result == 0.0) {
Packit Service a2489d
    
Packit Service a2489d
#if defined(INFINITY) && defined(__STDC_IEC_559__)
Packit Service a2489d
    result = (double)INFINITY;
Packit Service a2489d
Packit Service a2489d
#elif defined(USE_IEEE_754)
Packit Service a2489d
    result = trio_make_double(ieee_754_infinity_array);
Packit Service a2489d
Packit Service a2489d
#else
Packit Service a2489d
    /*
Packit Service a2489d
     * If HUGE_VAL is different from DBL_MAX, then HUGE_VAL is used
Packit Service a2489d
     * as infinity. Otherwise we have to resort to an overflow
Packit Service a2489d
     * operation to generate infinity.
Packit Service a2489d
     */
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
Packit Service a2489d
# endif
Packit Service a2489d
Packit Service a2489d
    result = HUGE_VAL;
Packit Service a2489d
    if (HUGE_VAL == DBL_MAX) {
Packit Service a2489d
      /* Force overflow */
Packit Service a2489d
      result += HUGE_VAL;
Packit Service a2489d
    }
Packit Service a2489d
    
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
    signal(SIGFPE, signal_handler);
Packit Service a2489d
# endif
Packit Service a2489d
Packit Service a2489d
#endif
Packit Service a2489d
  }
Packit Service a2489d
  return result;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Generate negative infinity.
Packit Service a2489d
Packit Service a2489d
   @return Floating-point value of negative infinity.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC double
Packit Service a2489d
trio_ninf(TRIO_NOARGS)
Packit Service a2489d
{
Packit Service a2489d
  static double result = 0.0;
Packit Service a2489d
Packit Service a2489d
  if (result == 0.0) {
Packit Service a2489d
    /*
Packit Service a2489d
     * Negative infinity is calculated by negating positive infinity,
Packit Service a2489d
     * which can be done because it is legal to do calculations on
Packit Service a2489d
     * infinity (for example,  1 / infinity == 0).
Packit Service a2489d
     */
Packit Service a2489d
    result = -trio_pinf();
Packit Service a2489d
  }
Packit Service a2489d
  return result;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Generate NaN.
Packit Service a2489d
Packit Service a2489d
   @return Floating-point representation of NaN.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC double
Packit Service a2489d
trio_nan(TRIO_NOARGS)
Packit Service a2489d
{
Packit Service a2489d
  /* Cache the result */
Packit Service a2489d
  static double result = 0.0;
Packit Service a2489d
Packit Service a2489d
  if (result == 0.0) {
Packit Service a2489d
    
Packit Service a2489d
#if defined(TRIO_COMPILER_SUPPORTS_C99)
Packit Service a2489d
    result = nan("");
Packit Service a2489d
Packit Service a2489d
#elif defined(NAN) && defined(__STDC_IEC_559__)
Packit Service a2489d
    result = (double)NAN;
Packit Service a2489d
  
Packit Service a2489d
#elif defined(USE_IEEE_754)
Packit Service a2489d
    result = trio_make_double(ieee_754_qnan_array);
Packit Service a2489d
Packit Service a2489d
#else
Packit Service a2489d
    /*
Packit Service a2489d
     * There are several ways to generate NaN. The one used here is
Packit Service a2489d
     * to divide infinity by infinity. I would have preferred to add
Packit Service a2489d
     * negative infinity to positive infinity, but that yields wrong
Packit Service a2489d
     * result (infinity) on FreeBSD.
Packit Service a2489d
     *
Packit Service a2489d
     * This may fail if the hardware does not support NaN, or if
Packit Service a2489d
     * the Invalid Operation floating-point exception is unmasked.
Packit Service a2489d
     */
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
    void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
Packit Service a2489d
# endif
Packit Service a2489d
    
Packit Service a2489d
    result = trio_pinf() / trio_pinf();
Packit Service a2489d
    
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
    signal(SIGFPE, signal_handler);
Packit Service a2489d
# endif
Packit Service a2489d
    
Packit Service a2489d
#endif
Packit Service a2489d
  }
Packit Service a2489d
  return result;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Check for NaN.
Packit Service a2489d
Packit Service a2489d
   @param number An arbitrary floating-point number.
Packit Service a2489d
   @return Boolean value indicating whether or not the number is a NaN.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_isnan
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
#if (defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isnan)) \
Packit Service a2489d
 || defined(TRIO_COMPILER_SUPPORTS_UNIX95)
Packit Service a2489d
  /*
Packit Service a2489d
   * C99 defines isnan() as a macro. UNIX95 defines isnan() as a
Packit Service a2489d
   * function. This function was already present in XPG4, but this
Packit Service a2489d
   * is a bit tricky to detect with compiler defines, so we choose
Packit Service a2489d
   * the conservative approach and only use it for UNIX95.
Packit Service a2489d
   */
Packit Service a2489d
  return isnan(number);
Packit Service a2489d
  
Packit Service a2489d
#elif defined(TRIO_COMPILER_MSVC)
Packit Service a2489d
  /*
Packit Service a2489d
   * MSVC has an _isnan() function
Packit Service a2489d
   */
Packit Service a2489d
  return _isnan(number);
Packit Service a2489d
Packit Service a2489d
#elif defined(USE_IEEE_754)
Packit Service a2489d
  /*
Packit Service a2489d
   * Examine IEEE 754 bit-pattern. A NaN must have a special exponent
Packit Service a2489d
   * pattern, and a non-empty mantissa.
Packit Service a2489d
   */
Packit Service a2489d
  int has_mantissa;
Packit Service a2489d
  int is_special_quantity;
Packit Service a2489d
Packit Service a2489d
  is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
Packit Service a2489d
  
Packit Service a2489d
  return (is_special_quantity && has_mantissa);
Packit Service a2489d
  
Packit Service a2489d
#else
Packit Service a2489d
  /*
Packit Service a2489d
   * Fallback solution
Packit Service a2489d
   */
Packit Service a2489d
  int status;
Packit Service a2489d
  double integral, fraction;
Packit Service a2489d
  
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  status = (/*
Packit Service a2489d
	     * NaN is the only number which does not compare to itself
Packit Service a2489d
	     */
Packit Service a2489d
	    ((TRIO_VOLATILE double)number != (TRIO_VOLATILE double)number) ||
Packit Service a2489d
	    /*
Packit Service a2489d
	     * Fallback solution if NaN compares to NaN
Packit Service a2489d
	     */
Packit Service a2489d
	    ((number != 0.0) &&
Packit Service a2489d
	     (fraction = modf(number, &integral),
Packit Service a2489d
	      integral == fraction)));
Packit Service a2489d
  
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  signal(SIGFPE, signal_handler);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  return status;
Packit Service a2489d
  
Packit Service a2489d
#endif
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Check for infinity.
Packit Service a2489d
Packit Service a2489d
   @param number An arbitrary floating-point number.
Packit Service a2489d
   @return 1 if positive infinity, -1 if negative infinity, 0 otherwise.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_isinf
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
#if defined(TRIO_COMPILER_DECC)
Packit Service a2489d
  /*
Packit Service a2489d
   * DECC has an isinf() macro, but it works differently than that
Packit Service a2489d
   * of C99, so we use the fp_class() function instead.
Packit Service a2489d
   */
Packit Service a2489d
  return ((fp_class(number) == FP_POS_INF)
Packit Service a2489d
	  ? 1
Packit Service a2489d
	  : ((fp_class(number) == FP_NEG_INF) ? -1 : 0));
Packit Service a2489d
Packit Service a2489d
#elif defined(isinf)
Packit Service a2489d
  /*
Packit Service a2489d
   * C99 defines isinf() as a macro.
Packit Service a2489d
   */
Packit Service a2489d
  return isinf(number)
Packit Service a2489d
    ? ((number > 0.0) ? 1 ; -1)
Packit Service a2489d
    : 0;
Packit Service a2489d
  
Packit Service a2489d
#elif defined(TRIO_COMPILER_MSVC)
Packit Service a2489d
  /*
Packit Service a2489d
   * MSVC has an _fpclass() function that can be used to detect infinity.
Packit Service a2489d
   */
Packit Service a2489d
  return ((_fpclass(number) == _FPCLASS_PINF)
Packit Service a2489d
	  ? 1
Packit Service a2489d
	  : ((_fpclass(number) == _FPCLASS_NINF) ? -1 : 0));
Packit Service a2489d
Packit Service a2489d
#elif defined(USE_IEEE_754)
Packit Service a2489d
  /*
Packit Service a2489d
   * Examine IEEE 754 bit-pattern. Infinity must have a special exponent
Packit Service a2489d
   * pattern, and an empty mantissa.
Packit Service a2489d
   */
Packit Service a2489d
  int has_mantissa;
Packit Service a2489d
  int is_special_quantity;
Packit Service a2489d
Packit Service a2489d
  is_special_quantity = trio_is_special_quantity(number, &has_mantissa);
Packit Service a2489d
  
Packit Service a2489d
  return (is_special_quantity && !has_mantissa)
Packit Service a2489d
    ? ((number < 0.0) ? -1 : 1)
Packit Service a2489d
    : 0;
Packit Service a2489d
Packit Service a2489d
#else
Packit Service a2489d
  /*
Packit Service a2489d
   * Fallback solution.
Packit Service a2489d
   */
Packit Service a2489d
  int status;
Packit Service a2489d
  
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  void (*signal_handler)(int) = signal(SIGFPE, SIG_IGN);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  double infinity = trio_pinf();
Packit Service a2489d
  
Packit Service a2489d
  status = ((number == infinity)
Packit Service a2489d
	    ? 1
Packit Service a2489d
	    : ((number == -infinity) ? -1 : 0));
Packit Service a2489d
  
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  signal(SIGFPE, signal_handler);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  return status;
Packit Service a2489d
  
Packit Service a2489d
#endif
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Check for finity.
Packit Service a2489d
Packit Service a2489d
   @param number An arbitrary floating-point number.
Packit Service a2489d
   @return Boolean value indicating whether or not the number is a finite.
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_isfinite
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
#if defined(TRIO_COMPILER_SUPPORTS_C99) && defined(isfinite)
Packit Service a2489d
  /*
Packit Service a2489d
   * C99 defines isfinite() as a macro.
Packit Service a2489d
   */
Packit Service a2489d
  return isfinite(number);
Packit Service a2489d
  
Packit Service a2489d
#elif defined(TRIO_COMPILER_MSVC)
Packit Service a2489d
  /*
Packit Service a2489d
   * MSVC uses _finite().
Packit Service a2489d
   */
Packit Service a2489d
  return _finite(number);
Packit Service a2489d
Packit Service a2489d
#elif defined(USE_IEEE_754)
Packit Service a2489d
  /*
Packit Service a2489d
   * Examine IEEE 754 bit-pattern. For finity we do not care about the
Packit Service a2489d
   * mantissa.
Packit Service a2489d
   */
Packit Service a2489d
  int dummy;
Packit Service a2489d
Packit Service a2489d
  return (! trio_is_special_quantity(number, &dummy));
Packit Service a2489d
Packit Service a2489d
#else
Packit Service a2489d
  /*
Packit Service a2489d
   * Fallback solution.
Packit Service a2489d
   */
Packit Service a2489d
  return ((trio_isinf(number) == 0) && (trio_isnan(number) == 0));
Packit Service a2489d
  
Packit Service a2489d
#endif
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/*
Packit Service a2489d
 * The sign of NaN is always false
Packit Service a2489d
 */
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_fpclassify_and_signbit
Packit Service a2489d
TRIO_ARGS2((number, is_negative),
Packit Service a2489d
	   double number,
Packit Service a2489d
	   int *is_negative)
Packit Service a2489d
{
Packit Service a2489d
#if defined(fpclassify) && defined(signbit)
Packit Service a2489d
  /*
Packit Service a2489d
   * C99 defines fpclassify() and signbit() as a macros
Packit Service a2489d
   */
Packit Service a2489d
  *is_negative = signbit(number);
Packit Service a2489d
  switch (fpclassify(number)) {
Packit Service a2489d
  case FP_NAN:
Packit Service a2489d
    return TRIO_FP_NAN;
Packit Service a2489d
  case FP_INFINITE:
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case FP_SUBNORMAL:
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case FP_ZERO:
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  default:
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  }
Packit Service a2489d
Packit Service a2489d
#elif defined(TRIO_COMPILER_DECC)
Packit Service a2489d
  /*
Packit Service a2489d
   * DECC has an fp_class() function.
Packit Service a2489d
   */
Packit Service a2489d
  switch (fp_class(number)) {
Packit Service a2489d
  case FP_QNAN:
Packit Service a2489d
  case FP_SNAN:
Packit Service a2489d
    *is_negative = TRIO_FALSE; /* NaN has no sign */
Packit Service a2489d
    return TRIO_FP_NAN;
Packit Service a2489d
  case FP_POS_INF:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case FP_NEG_INF:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case FP_POS_DENORM:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case FP_NEG_DENORM:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case FP_POS_ZERO:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case FP_NEG_ZERO:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case FP_POS_NORM:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  case FP_NEG_NORM:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  default:
Packit Service a2489d
    /* Just in case... */
Packit Service a2489d
    *is_negative = (number < 0.0);
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  }
Packit Service a2489d
Packit Service a2489d
#elif defined(TRIO_COMPILER_MSVC)
Packit Service a2489d
  /*
Packit Service a2489d
   * MSVC has an _fpclass() function.
Packit Service a2489d
   */
Packit Service a2489d
  switch (_fpclass(number)) {
Packit Service a2489d
  case _FPCLASS_QNAN:
Packit Service a2489d
  case _FPCLASS_SNAN:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NAN;
Packit Service a2489d
  case _FPCLASS_PINF:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case _FPCLASS_NINF:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case _FPCLASS_PD:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case _FPCLASS_ND:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case _FPCLASS_PZ:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case _FPCLASS_NZ:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case _FPCLASS_PN:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  case _FPCLASS_NN:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  default:
Packit Service a2489d
    /* Just in case... */
Packit Service a2489d
    *is_negative = (number < 0.0);
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  }
Packit Service a2489d
Packit Service a2489d
#elif defined(FP_PLUS_NORM) || defined(__hpux)
Packit Service a2489d
Packit Service a2489d
  /*
Packit Service a2489d
   * HP-UX 9.x and 10.x have an fpclassify() function, that is different
Packit Service a2489d
   * from the C99 fpclassify() macro supported on HP-UX 11.x.
Packit Service a2489d
   */
Packit Service a2489d
  switch (fpclassify(number)) {
Packit Service a2489d
  case FP_QNAN:
Packit Service a2489d
  case FP_SNAN:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NAN;
Packit Service a2489d
  case FP_PLUS_INF:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case FP_MINUS_INF:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  case FP_PLUS_DENORM:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case FP_MINUS_DENORM:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  case FP_PLUS_ZERO:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case FP_MINUS_ZERO:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  case FP_PLUS_NORM:
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  case FP_MINUS_NORM:
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_NORMAL;
Packit Service a2489d
  default:
Packit Service a2489d
    assert(0);
Packit Service a2489d
  }
Packit Service a2489d
Packit Service a2489d
#else
Packit Service a2489d
  /*
Packit Service a2489d
   * Fallback solution.
Packit Service a2489d
   */
Packit Service a2489d
  int rc;
Packit Service a2489d
  
Packit Service a2489d
  if (number == 0.0) {
Packit Service a2489d
    /*
Packit Service a2489d
     * In IEEE 754 the sign of zero is ignored in comparisons, so we
Packit Service a2489d
     * have to handle this as a special case by examining the sign bit
Packit Service a2489d
     * directly.
Packit Service a2489d
     */
Packit Service a2489d
#if defined(USE_IEEE_754)
Packit Service a2489d
    *is_negative = trio_is_negative(number);
Packit Service a2489d
#else
Packit Service a2489d
    *is_negative = TRIO_FALSE; /* FIXME */
Packit Service a2489d
#endif
Packit Service a2489d
    return TRIO_FP_ZERO;
Packit Service a2489d
  }
Packit Service a2489d
  if (trio_isnan(number)) {
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_NAN;
Packit Service a2489d
  }
Packit Service a2489d
  if ((rc = trio_isinf(number))) {
Packit Service a2489d
    *is_negative = (rc == -1);
Packit Service a2489d
    return TRIO_FP_INFINITE;
Packit Service a2489d
  }
Packit Service a2489d
  if ((number > 0.0) && (number < DBL_MIN)) {
Packit Service a2489d
    *is_negative = TRIO_FALSE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  }
Packit Service a2489d
  if ((number < 0.0) && (number > -DBL_MIN)) {
Packit Service a2489d
    *is_negative = TRIO_TRUE;
Packit Service a2489d
    return TRIO_FP_SUBNORMAL;
Packit Service a2489d
  }
Packit Service a2489d
  *is_negative = (number < 0.0);
Packit Service a2489d
  return TRIO_FP_NORMAL;
Packit Service a2489d
  
Packit Service a2489d
#endif
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Examine the sign of a number.
Packit Service a2489d
Packit Service a2489d
   @param number An arbitrary floating-point number.
Packit Service a2489d
   @return Boolean value indicating whether or not the number has the
Packit Service a2489d
   sign bit set (i.e. is negative).
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_signbit
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
  int is_negative;
Packit Service a2489d
  
Packit Service a2489d
  (void)trio_fpclassify_and_signbit(number, &is_negative);
Packit Service a2489d
  return is_negative;
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
/**
Packit Service a2489d
   Examine the class of a number.
Packit Service a2489d
Packit Service a2489d
   @param number An arbitrary floating-point number.
Packit Service a2489d
   @return Enumerable value indicating the class of @p number
Packit Service a2489d
*/
Packit Service a2489d
TRIO_PUBLIC int
Packit Service a2489d
trio_fpclassify
Packit Service a2489d
TRIO_ARGS1((number),
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
  int dummy;
Packit Service a2489d
  
Packit Service a2489d
  return trio_fpclassify_and_signbit(number, &dummy);
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
Packit Service a2489d
/** @} SpecialQuantities */
Packit Service a2489d
Packit Service a2489d
/*************************************************************************
Packit Service a2489d
 * For test purposes.
Packit Service a2489d
 *
Packit Service a2489d
 * Add the following compiler option to include this test code.
Packit Service a2489d
 *
Packit Service a2489d
 *  Unix : -DSTANDALONE
Packit Service a2489d
 *  VMS  : /DEFINE=(STANDALONE)
Packit Service a2489d
 */
Packit Service a2489d
#if defined(STANDALONE)
Packit Service a2489d
# include <stdio.h>
Packit Service a2489d
Packit Service a2489d
static TRIO_CONST char *
Packit Service a2489d
getClassification
Packit Service a2489d
TRIO_ARGS1((type)
Packit Service a2489d
	   int type)
Packit Service a2489d
{
Packit Service a2489d
  switch (type) {
Packit Service a2489d
  case TRIO_FP_INFINITE:
Packit Service a2489d
    return "FP_INFINITE";
Packit Service a2489d
  case TRIO_FP_NAN:
Packit Service a2489d
    return "FP_NAN";
Packit Service a2489d
  case TRIO_FP_NORMAL:
Packit Service a2489d
    return "FP_NORMAL";
Packit Service a2489d
  case TRIO_FP_SUBNORMAL:
Packit Service a2489d
    return "FP_SUBNORMAL";
Packit Service a2489d
  case TRIO_FP_ZERO:
Packit Service a2489d
    return "FP_ZERO";
Packit Service a2489d
  default:
Packit Service a2489d
    return "FP_UNKNOWN";
Packit Service a2489d
  }
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
static void
Packit Service a2489d
print_class
Packit Service a2489d
TRIO_ARGS2((prefix, number)
Packit Service a2489d
	   TRIO_CONST char *prefix,
Packit Service a2489d
	   double number)
Packit Service a2489d
{
Packit Service a2489d
  printf("%-6s: %s %-15s %g\n",
Packit Service a2489d
	 prefix,
Packit Service a2489d
	 trio_signbit(number) ? "-" : "+",
Packit Service a2489d
	 getClassification(trio_fpclassify(number)),
Packit Service a2489d
	 number);
Packit Service a2489d
}
Packit Service a2489d
Packit Service a2489d
int main(TRIO_NOARGS)
Packit Service a2489d
{
Packit Service a2489d
  double my_nan;
Packit Service a2489d
  double my_pinf;
Packit Service a2489d
  double my_ninf;
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  void (*signal_handler) TRIO_PROTO((int));
Packit Service a2489d
# endif
Packit Service a2489d
Packit Service a2489d
  my_nan = trio_nan();
Packit Service a2489d
  my_pinf = trio_pinf();
Packit Service a2489d
  my_ninf = trio_ninf();
Packit Service a2489d
Packit Service a2489d
  print_class("Nan", my_nan);
Packit Service a2489d
  print_class("PInf", my_pinf);
Packit Service a2489d
  print_class("NInf", my_ninf);
Packit Service a2489d
  print_class("PZero", 0.0);
Packit Service a2489d
  print_class("NZero", -0.0);
Packit Service a2489d
  print_class("PNorm", 1.0);
Packit Service a2489d
  print_class("NNorm", -1.0);
Packit Service a2489d
  print_class("PSub", 1.01e-307 - 1.00e-307);
Packit Service a2489d
  print_class("NSub", 1.00e-307 - 1.01e-307);
Packit Service a2489d
  
Packit Service a2489d
  printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_nan,
Packit Service a2489d
	 ((unsigned char *)&my_nan)[0],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[1],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[2],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[3],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[4],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[5],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[6],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[7],
Packit Service a2489d
	 trio_isnan(my_nan), trio_isinf(my_nan));
Packit Service a2489d
  printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_pinf,
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[0],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[1],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[2],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[3],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[4],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[5],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[6],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[7],
Packit Service a2489d
	 trio_isnan(my_pinf), trio_isinf(my_pinf));
Packit Service a2489d
  printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_ninf,
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[0],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[1],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[2],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[3],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[4],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[5],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[6],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[7],
Packit Service a2489d
	 trio_isnan(my_ninf), trio_isinf(my_ninf));
Packit Service a2489d
  
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  signal_handler = signal(SIGFPE, SIG_IGN);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  my_pinf = DBL_MAX + DBL_MAX;
Packit Service a2489d
  my_ninf = -my_pinf;
Packit Service a2489d
  my_nan = my_pinf / my_pinf;
Packit Service a2489d
Packit Service a2489d
# if defined(TRIO_PLATFORM_UNIX)
Packit Service a2489d
  signal(SIGFPE, signal_handler);
Packit Service a2489d
# endif
Packit Service a2489d
  
Packit Service a2489d
  printf("NaN : %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_nan,
Packit Service a2489d
	 ((unsigned char *)&my_nan)[0],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[1],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[2],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[3],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[4],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[5],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[6],
Packit Service a2489d
	 ((unsigned char *)&my_nan)[7],
Packit Service a2489d
	 trio_isnan(my_nan), trio_isinf(my_nan));
Packit Service a2489d
  printf("PInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_pinf,
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[0],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[1],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[2],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[3],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[4],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[5],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[6],
Packit Service a2489d
	 ((unsigned char *)&my_pinf)[7],
Packit Service a2489d
	 trio_isnan(my_pinf), trio_isinf(my_pinf));
Packit Service a2489d
  printf("NInf: %4g 0x%02x%02x%02x%02x%02x%02x%02x%02x (%2d, %2d)\n",
Packit Service a2489d
	 my_ninf,
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[0],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[1],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[2],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[3],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[4],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[5],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[6],
Packit Service a2489d
	 ((unsigned char *)&my_ninf)[7],
Packit Service a2489d
	 trio_isnan(my_ninf), trio_isinf(my_ninf));
Packit Service a2489d
	 
Packit Service a2489d
  return 0;
Packit Service a2489d
}
Packit Service a2489d
#endif