#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_equal (int *pres, UINT64 * px,
+bid64_quiet_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_equal (UINT64 x,
+bid64_quiet_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
res = (((x ^ y) & MASK_SIGN) != MASK_SIGN);
BID_RETURN (res);
}
+ // ONE INFINITY (CASE3')
+ if (((x & MASK_INF) == MASK_INF) || ((y & MASK_INF) == MASK_INF)) {
+ res = 0;
+ BID_RETURN (res);
+ }
// if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
exp_x = (x & MASK_BINARY_EXPONENT2) >> 51;
BID_RETURN (res);
}
// REDUNDANT REPRESENTATIONS (CASE6)
- if (exp_x > exp_y) { // to simplify the loop below,
- SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
- SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
+ if (exp_x > exp_y) { // to simplify the loop below,
+ SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
+ SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
}
if (exp_y - exp_x > 15) {
- res = 0; // difference cannot be greater than 10^15
+ res = 0; // difference cannot be greater than 10^15
BID_RETURN (res);
}
for (lcv = 0; lcv < (exp_y - exp_x); lcv++) {
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_greater (int *pres, UINT64 * px,
+bid64_quiet_greater (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_greater (UINT64 x,
+bid64_quiet_greater (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
BID_RETURN (res);
}
// if exp_x is 15 greater than exp_y, no need for compensation
- if (exp_x - exp_y > 15) { // difference cannot be greater than 10^15
+ if (exp_x - exp_y > 15) { // difference cannot be greater than 10^15
if (x & MASK_SIGN) // if both are negative
res = 0;
else // if both are positive
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_greater_equal (int *pres, UINT64 * px,
+bid64_quiet_greater_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_greater_equal (UINT64 x,
+bid64_quiet_greater_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered : return 1
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
res = (((y & MASK_INF) == MASK_INF)
&& (y & MASK_SIGN) == MASK_SIGN);
BID_RETURN (res);
- } else { // x is pos_inf, no way for it to be less than y
+ } else { // x is pos_inf, no way for it to be less than y
res = 1;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_greater_unordered (int *pres, UINT64 * px,
+bid64_quiet_greater_unordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_greater_unordered (UINT64 x,
+bid64_quiet_greater_unordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM
_EXC_MASKS_PARAM _EXC_INFO_PARAM) {
#endif
// return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_less (int *pres, UINT64 * px,
+bid64_quiet_less (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM)
{
UINT64 y = *py;
#else
int
-__bid64_quiet_less (UINT64 x,
+bid64_quiet_less (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_less_equal (int *pres, UINT64 * px,
+bid64_quiet_less_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_less_equal (UINT64 x,
+bid64_quiet_less_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_less_unordered (int *pres, UINT64 * px,
+bid64_quiet_less_unordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_less_unordered (UINT64 x,
+bid64_quiet_less_unordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
mult_factor[exp_x - exp_y]);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_not_equal (int *pres, UINT64 * px,
+bid64_quiet_not_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_not_equal (UINT64 x,
+bid64_quiet_not_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// rather than equal : return 1
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
res = (((x ^ y) & MASK_SIGN) == MASK_SIGN);
BID_RETURN (res);
}
+ // ONE INFINITY (CASE3')
+ if (((x & MASK_INF) == MASK_INF) || ((y & MASK_INF) == MASK_INF)) {
+ res = 1;
+ BID_RETURN (res);
+ }
// if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
exp_x = (x & MASK_BINARY_EXPONENT2) >> 51;
BID_RETURN (res);
}
// REDUNDANT REPRESENTATIONS (CASE6)
- if (exp_x > exp_y) { // to simplify the loop below,
- SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
- SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
+ if (exp_x > exp_y) { // to simplify the loop below,
+ SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
+ SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
}
if (exp_y - exp_x > 15) {
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_not_greater (int *pres, UINT64 * px,
+bid64_quiet_not_greater (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_not_greater (UINT64 x,
+bid64_quiet_not_greater (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_not_less (int *pres, UINT64 * px,
+bid64_quiet_not_less (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_not_less (UINT64 x,
+bid64_quiet_not_less (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered : return 1
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_ordered (int *pres, UINT64 * px,
+bid64_quiet_ordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_ordered (UINT64 x,
+bid64_quiet_ordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is ordered, rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 0;
BID_RETURN (res);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_quiet_unordered (int *pres, UINT64 * px,
+bid64_quiet_unordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_quiet_unordered (UINT64 x,
+bid64_quiet_unordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
if ((x & MASK_SNAN) == MASK_SNAN || (y & MASK_SNAN) == MASK_SNAN) {
- *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
+ *pfpsf |= INVALID_EXCEPTION; // set exception if sNaN
}
res = 1;
BID_RETURN (res);
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_equal (int *pres, UINT64 * px,
- UINT64 *
- py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
- UINT64 x = *px;
- UINT64 y = *py;
-#else
-int
-__bid64_signaling_equal (UINT64 x,
- UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
-#endif
- int res;
- int exp_x, exp_y, exp_t;
- UINT64 sig_x, sig_y, sig_t;
- char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y, lcv;
-
- // NaN (CASE1)
- // if either number is NAN, the comparison is unordered,
- // rather than equal : return 0
- if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
- res = 0;
- BID_RETURN (res);
- }
- // SIMPLE (CASE2)
- // if all the bits are the same, these numbers are equivalent.
- if (x == y) {
- res = 1;
- BID_RETURN (res);
- }
- // INFINITY (CASE3)
- if (((x & MASK_INF) == MASK_INF) && ((y & MASK_INF) == MASK_INF)) {
- res = (((x ^ y) & MASK_SIGN) != MASK_SIGN);
- BID_RETURN (res);
- }
- // if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
- if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
- exp_x = (x & MASK_BINARY_EXPONENT2) >> 51;
- sig_x = (x & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
- if (sig_x > 9999999999999999ull) {
- non_canon_x = 1;
- } else {
- non_canon_x = 0;
- }
- } else {
- exp_x = (x & MASK_BINARY_EXPONENT1) >> 53;
- sig_x = (x & MASK_BINARY_SIG1);
- non_canon_x = 0;
- }
-
- // if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
- if ((y & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
- exp_y = (y & MASK_BINARY_EXPONENT2) >> 51;
- sig_y = (y & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
- if (sig_y > 9999999999999999ull) {
- non_canon_y = 1;
- } else {
- non_canon_y = 0;
- }
- } else {
- exp_y = (y & MASK_BINARY_EXPONENT1) >> 53;
- sig_y = (y & MASK_BINARY_SIG1);
- non_canon_y = 0;
- }
-
- // ZERO (CASE4)
- // some properties:
- // (+ZERO==-ZERO) => therefore ignore the sign
- // (ZERO x 10^A == ZERO x 10^B) for any valid A, B =>
- // therefore ignore the exponent field
- // (Any non-canonical # is considered 0)
- if (non_canon_x || sig_x == 0) {
- x_is_zero = 1;
- }
- if (non_canon_y || sig_y == 0) {
- y_is_zero = 1;
- }
-
- if (x_is_zero && y_is_zero) {
- res = 1;
- BID_RETURN (res);
- } else if ((x_is_zero && !y_is_zero) || (!x_is_zero && y_is_zero)) {
- res = 0;
- BID_RETURN (res);
- }
- // OPPOSITE SIGN (CASE5)
- // now, if the sign bits differ => not equal : return 0
- if ((x ^ y) & MASK_SIGN) {
- res = 0;
- BID_RETURN (res);
- }
- // REDUNDANT REPRESENTATIONS (CASE6)
- if (exp_x > exp_y) { // to simplify the loop below,
- SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
- SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
- }
-
- if (exp_y - exp_x > 15) {
- res = 0;
- BID_RETURN (res);
- }
- // difference cannot be greater than 10^15
-
- for (lcv = 0; lcv < (exp_y - exp_x); lcv++) {
-
- // recalculate y's significand upwards
- sig_y = sig_y * 10;
- if (sig_y > 9999999999999999ull) {
- res = 0;
- BID_RETURN (res);
- }
- }
-
- {
- res = sig_y == sig_x;
- BID_RETURN (res);
- }
-
-}
-
-#if DECIMAL_CALL_BY_REFERENCE
-void
-__bid64_signaling_greater (int *pres, UINT64 * px,
+bid64_signaling_greater (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_greater (UINT64 x,
+bid64_signaling_greater (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered,
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 0;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_greater_equal (int *pres, UINT64 * px,
+bid64_signaling_greater_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_greater_equal (UINT64 x,
+bid64_signaling_greater_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM
_EXC_MASKS_PARAM _EXC_INFO_PARAM) {
#endif
// NaN (CASE1)
// if either number is NAN, the comparison is unordered : return 1
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 0;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_greater_unordered (int *pres, UINT64 * px,
+bid64_signaling_greater_unordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_greater_unordered (UINT64 x,
+bid64_signaling_greater_unordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM
_EXC_MASKS_PARAM _EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered,
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 1;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_less (int *pres, UINT64 * px,
+bid64_signaling_less (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_less (UINT64 x,
+bid64_signaling_less (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// NaN (CASE1)
// if either number is NAN, the comparison is unordered : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 0;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_less_equal (int *pres, UINT64 * px,
+bid64_signaling_less_equal (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_less_equal (UINT64 x,
+bid64_signaling_less_equal (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered,
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 0;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_less_unordered (int *pres, UINT64 * px,
+bid64_signaling_less_unordered (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_less_unordered (UINT64 x,
+bid64_signaling_less_unordered (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM
_EXC_MASKS_PARAM _EXC_INFO_PARAM) {
#endif
// NaN (CASE1)
// if either number is NAN, the comparison is unordered : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 1;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_not_equal (int *pres, UINT64 * px,
- UINT64 *
- py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
- UINT64 x = *px;
- UINT64 y = *py;
-#else
-int
-__bid64_signaling_not_equal (UINT64 x,
- UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
-#endif
- int res;
- int exp_x, exp_y, exp_t;
- UINT64 sig_x, sig_y, sig_t;
- char x_is_zero = 0, y_is_zero = 0, non_canon_x, non_canon_y, lcv;
-
- // NaN (CASE1)
- // if either number is NAN, the comparison is unordered,
- // rather than equal : return 1
- if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
- res = 1;
- BID_RETURN (res);
- }
- // SIMPLE (CASE2)
- // if all the bits are the same, these numbers are equivalent.
- if (x == y) {
- res = 0;
- BID_RETURN (res);
- }
- // INFINITY (CASE3)
- if (((x & MASK_INF) == MASK_INF) && ((y & MASK_INF) == MASK_INF)) {
- res = (((x ^ y) & MASK_SIGN) == MASK_SIGN);
- BID_RETURN (res);
- }
- // if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
- if ((x & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
- exp_x = (x & MASK_BINARY_EXPONENT2) >> 51;
- sig_x = (x & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
- if (sig_x > 9999999999999999ull) {
- non_canon_x = 1;
- } else {
- non_canon_x = 0;
- }
- } else {
- exp_x = (x & MASK_BINARY_EXPONENT1) >> 53;
- sig_x = (x & MASK_BINARY_SIG1);
- non_canon_x = 0;
- }
-
- // if steering bits are 11 (condition will be 0), then exponent is G[0:w+1] =>
- if ((y & MASK_STEERING_BITS) == MASK_STEERING_BITS) {
- exp_y = (y & MASK_BINARY_EXPONENT2) >> 51;
- sig_y = (y & MASK_BINARY_SIG2) | MASK_BINARY_OR2;
- if (sig_y > 9999999999999999ull) {
- non_canon_y = 1;
- } else {
- non_canon_y = 0;
- }
- } else {
- exp_y = (y & MASK_BINARY_EXPONENT1) >> 53;
- sig_y = (y & MASK_BINARY_SIG1);
- non_canon_y = 0;
- }
-
- // ZERO (CASE4)
- // some properties:
- // (+ZERO==-ZERO) => therefore ignore the sign
- // (ZERO x 10^A == ZERO x 10^B) for any valid A, B =>
- // therefore ignore the exponent field
- // (Any non-canonical # is considered 0)
- if (non_canon_x || sig_x == 0) {
- x_is_zero = 1;
- }
- if (non_canon_y || sig_y == 0) {
- y_is_zero = 1;
- }
-
- if (x_is_zero && y_is_zero) {
- res = 0;
- BID_RETURN (res);
- } else if ((x_is_zero && !y_is_zero) || (!x_is_zero && y_is_zero)) {
- res = 1;
- BID_RETURN (res);
- }
- // OPPOSITE SIGN (CASE5)
- // now, if the sign bits differ => not equal : return 1
- if ((x ^ y) & MASK_SIGN) {
- res = 1;
- BID_RETURN (res);
- }
- // REDUNDANT REPRESENTATIONS (CASE6)
- if (exp_x > exp_y) { // to simplify the loop below,
- SWAP (exp_x, exp_y, exp_t); // put the larger exp in y,
- SWAP (sig_x, sig_y, sig_t); // and the smaller exp in x
- }
-
- if (exp_y - exp_x > 15) {
- res = 1;
- BID_RETURN (res);
- }
- // difference cannot be greater than 10^16
-
- for (lcv = 0; lcv < (exp_y - exp_x); lcv++) {
-
- // recalculate y's significand upwards
- sig_y = sig_y * 10;
- if (sig_y > 9999999999999999ull) {
- res = 1;
- BID_RETURN (res);
- }
- }
-
- {
- res = sig_y != sig_x;
- BID_RETURN (res);
- }
-
-}
-
-#if DECIMAL_CALL_BY_REFERENCE
-void
-__bid64_signaling_not_greater (int *pres, UINT64 * px,
+bid64_signaling_not_greater (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_not_greater (UINT64 x,
+bid64_signaling_not_greater (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// if either number is NAN, the comparison is unordered,
// rather than equal : return 0
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 1;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
#if DECIMAL_CALL_BY_REFERENCE
void
-__bid64_signaling_not_less (int *pres, UINT64 * px,
+bid64_signaling_not_less (int *pres, UINT64 * px,
UINT64 *
py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
UINT64 y = *py;
#else
int
-__bid64_signaling_not_less (UINT64 x,
+bid64_signaling_not_less (UINT64 x,
UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
_EXC_INFO_PARAM) {
#endif
// NaN (CASE1)
// if either number is NAN, the comparison is unordered : return 1
if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
+ *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
res = 1;
BID_RETURN (res);
}
BID_RETURN (res);
}
// if |exp_x - exp_y| < 15, it comes down to the compensated significand
- if (exp_x > exp_y) { // to simplify the loop below,
+ if (exp_x > exp_y) { // to simplify the loop below,
// otherwise adjust the x significand upwards
__mul_64x64_to_128MACH (sig_n_prime, sig_x,
BID_RETURN (res);
}
}
-
-#if DECIMAL_CALL_BY_REFERENCE
-void
-__bid64_signaling_ordered (int *pres, UINT64 * px,
- UINT64 *
- py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
- UINT64 x = *px;
- UINT64 y = *py;
-#else
-int
-__bid64_signaling_ordered (UINT64 x,
- UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
-#endif
- int res;
-
- // NaN (CASE1)
- // if either number is NAN, the comparison is ordered,
- // rather than equal : return 0
- if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
- res = 0;
- BID_RETURN (res);
- } else {
- res = 1;
- BID_RETURN (res);
- }
-}
-
-#if DECIMAL_CALL_BY_REFERENCE
-void
-__bid64_signaling_unordered (int *pres, UINT64 * px,
- UINT64 *
- py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
- UINT64 x = *px;
- UINT64 y = *py;
-#else
-int
-__bid64_signaling_unordered (UINT64 x,
- UINT64 y _EXC_FLAGS_PARAM _EXC_MASKS_PARAM
- _EXC_INFO_PARAM) {
-#endif
- int res;
-
- // NaN (CASE1)
- // if either number is NAN, the comparison is unordered,
- // rather than equal : return 0
- if (((x & MASK_NAN) == MASK_NAN) || ((y & MASK_NAN) == MASK_NAN)) {
- *pfpsf |= INVALID_EXCEPTION; // set invalid exception if NaN
- res = 1;
- BID_RETURN (res);
- } else {
- res = 0;
- BID_RETURN (res);
- }
-}