_f_log8 _IEEE_IS_NAN_L8_D( _f_real16 x) { /* if x is NaN, return TRUE */ return ((_f_log8) _btol(isnan128(x))); }
inline static /* for the inline version of this function. */ #endif #define MIN(a,b) ((a) < (b) ? (a) : (b)) /*** Algorithm for f90 FRACTION * FRACTION - return the fractional part of the 128-bit model * representation of the argument value. **/ _f_real16 _FRACTION_16(_f_real16 x) { int lz, ileadzcnt, loopn; #if defined(_WORD32) union ldble_float { _f_real16 whole; unsigned long long ui[1]; } f, result, mantissa; unsigned long long sign_bit, exponent; #else union ldble_float { _f_real16 whole; unsigned long ui[1]; } f, result; unsigned long sign_bit, exponent; #endif static int word_size = 64; if (x == 0.0) return 0.0; f.whole = x; /* if x is either infinity or a NaN, return a Nan */ if ((f.ui[0] == IEEE_128_64_EXPO) && (f.ui[1] == 0)) return _DBL_NaN; if (isnan128(x)) return x; /* get sign bit. */ sign_bit = IEEE_128_64_SIGN_BIT & f.ui[0]; /* Get the absolute value of x by ANDing the upper half * with the NOT of 0x8000000000000000 (the sign bit mask). */ f.ui[0] &= ~IEEE_128_64_SIGN_BIT; /* get exponent. */ exponent = f.ui[0] & IEEE_128_64_EXPO; /* get mantissa and zero out exponent portion */ f.ui[0] &= IEEE_128_64_MANT1; result.whole = f.whole; if (exponent == LL_CONST(0x0)) { /* 1. Number is subnormal. Normalize mantissa and * get leading zeros in mantissa */ lz = 0; for (loopn = 0; loopn < 2; loopn++) { ileadzcnt = _leadz8(f.ui[loopn]); lz += ileadzcnt; if (ileadzcnt < word_size) break; } lz = lz - IEEE_128_EXPO_BITS; /* 2. Normalize by shifting out all leading zeros * and first 1 bit. * Determine number of mantissa bits in first 64 bits * of the mantissa plus the implicit bit. */ ileadzcnt = word_size - IEEE_128_EXPO_BITS; if (lz >= ileadzcnt) { /* The first 48 bits of the mantissa are zero. */ result.ui[0] = (f.ui[1] << (lz - ileadzcnt)) >> IEEE_128_EXPO_BITS; result.ui[1] = f.ui[1] << (MIN(word_size,lz)); } else {
/* _IEEE_EXPONENT_I6_D - IEEE EXPONENT returns the exponent part of the * 128-bit argument in 46-bit integer. */ _f_int6 _IEEE_EXPONENT_I6_D(_f_real16 x) { int i, ileadzcnt, loopn; #if defined(_WORD32) union ldble_float { _f_real16 whole; unsigned long long ui[2]; long long si[2]; } f, result; #else union ldble_float { _f_real16 whole; unsigned long ui[2]; long si[2]; } f, result; #endif static int word_size = 64; /* if x is a NaN, return a HUGE */ if (isnan128(x)) return HUGE_INT6_F90; f.whole = x; /* Get the absolute value of x by ANDing the upper half * with the NOT of 0x8000000000000000 (the sign bit mask). */ f.ui[0] &= ~IEEE_128_64_SIGN_BIT; /* if x is + or -infinity, return a HUGE */ if ((f.ui[0] == IEEE_128_64_EXPO) && (f.ui[1] == 0)) return HUGE_INT6_F90; /* if x is zero, return -HUGE */ if (x == 0.0e0) return -HUGE_INT6_F90; /* Separate the exponent from the 128-bit float value and * right justify it. */ result.ui[0] = f.ui[0] >> (IEEE_128_MANT_BITS - word_size); if (result.ui[0] == 0) { /* x is a subnormal number (implicit leading bit is zero * and the exponent is zero). Calculate the exponent * based on normalized x. * * get mantissa */ f.ui[0] &= IEEE_128_64_MANT1; i = 0; /* get leading zeros in mantissa part */ for (loopn = 0; loopn < 2; loopn++) { ileadzcnt = _leadz8(f.ui[loopn]); i += ileadzcnt; if (ileadzcnt < word_size) break; } i = i - IEEE_128_EXPO_BITS; /* calculate exponent. */ result.si[0] -= (IEEE_128_EXPO_BIAS + i); } else { /* subtract exponent bias. */ result.si[0] -= (IEEE_128_EXPO_BIAS); } return (_f_int6) result.si[0]; }