default:
break;
}
+ assert(int_float->desc.explicit_one <= 1);
+
/* pack sign: move it to the left after exponent AND mantissa */
sc_val_from_ulong(int_float->sign, temp);
}
/**
- * Operations involving NaN's must return NaN
+ * Operations involving NaN's must return NaN.
+ * They are NOT exact.
*/
#define handle_NAN(a, b, result) \
do { \
if (a->desc.clss == NAN) { \
if (a != result) memcpy(result, a, calc_buffer_size); \
+ fc_exact = 0; \
return; \
} \
if (b->desc.clss == NAN) { \
if (b != result) memcpy(result, b, calc_buffer_size); \
+ fc_exact = 0; \
return; \
} \
}while (0)
/* produce NaN on inf - inf */
if (sign && (a->desc.clss == INF) && (b->desc.clss == INF)) {
+ fc_exact = 0;
fc_get_qnan(&a->desc, result);
return;
}
if (a->desc.clss == ZERO || b->desc.clss == INF) {
if (b != result)
memcpy(result, b, calc_buffer_size);
+ fc_exact = b->desc.clss == NORMAL;
result->sign = res_sign;
return;
}
if (b->desc.clss == ZERO || a->desc.clss == INF) {
if (a != result)
memcpy(result, a, calc_buffer_size);
+ fc_exact = a->desc.clss == NORMAL;
result->sign = res_sign;
return;
}
/* produce NaN on 0 * inf */
if (a->desc.clss == ZERO) {
- if (b->desc.clss == INF)
+ if (b->desc.clss == INF) {
fc_get_qnan(&a->desc, result);
- else {
+ fc_exact = 0;
+ } else {
if (a != result)
memcpy(result, a, calc_buffer_size);
result->sign = res_sign;
return;
}
if (b->desc.clss == ZERO) {
- if (a->desc.clss == INF)
+ if (a->desc.clss == INF) {
fc_get_qnan(&a->desc, result);
- else {
+ fc_exact = 0;
+ } else {
if (b != result)
memcpy(result, b, calc_buffer_size);
result->sign = res_sign;
}
if (a->desc.clss == INF) {
+ fc_exact = 0;
if (a != result)
memcpy(result, a, calc_buffer_size);
result->sign = res_sign;
return;
}
if (b->desc.clss == INF) {
+ fc_exact = 0;
if (b != result)
memcpy(result, b, calc_buffer_size);
result->sign = res_sign;
/* produce NAN on 0/0 and inf/inf */
if (a->desc.clss == ZERO) {
- if (b->desc.clss == ZERO)
+ if (b->desc.clss == ZERO) {
/* 0/0 -> NaN */
fc_get_qnan(&a->desc, result);
- else {
+ fc_exact = 0;
+ } else {
/* 0/x -> a */
if (a != result)
memcpy(result, a, calc_buffer_size);
}
if (b->desc.clss == INF) {
- if (a->desc.clss == INF)
+ fc_exact = 0;
+ if (a->desc.clss == INF) {
/* inf/inf -> NaN */
fc_get_qnan(&a->desc, result);
- else {
+ } else {
/* x/inf -> 0 */
sc_val_from_ulong(0, NULL);
_save_result(_exp(result));
}
if (a->desc.clss == INF) {
+ fc_exact = 0;
/* inf/x -> inf */
if (a != result)
memcpy(result, a, calc_buffer_size);
return;
}
if (b->desc.clss == ZERO) {
+ fc_exact = 0;
/* division by zero */
if (result->sign)
fc_get_minusinf(&a->desc, result);