* @author Mathias Heil
* @version $Id$
*/
-
#include "config.h"
#include "fltcalc.h"
#include "strcalc.h"
-#include <math.h> /* need isnan() and isinf() (will be changed)*/
+#include <math.h>
/* undef some reused constants defined by math.h */
#ifdef NAN
# undef NAN
#endif
-#ifdef HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
+#include <inttypes.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
else
return fc_get_snan(desc, result);
}
+ else if(value->desc.clss == INF) {
+ if (value->sign == 0)
+ return fc_get_plusinf(desc, result);
+ else
+ return fc_get_minusinf(desc, result);
+ }
/* set the descriptor of the new value */
result->desc.exponent_size = desc->exponent_size;
return result;
}
-fp_value *fc_get_plusinf(const ieee_descriptor_t *desc, fp_value *result) {
+fp_value *fc_get_plusinf(const ieee_descriptor_t *desc, fp_value *result)
+{
+ char *mant;
+
if (result == NULL) result = calc_buffer;
result->desc.exponent_size = desc->exponent_size;
sc_val_from_ulong((1 << desc->exponent_size) - 1, _exp(result));
- sc_val_from_ulong(0, _mant(result));
+ mant = _mant(result);
+ sc_val_from_ulong(0, mant);
+ if (desc->explicit_one) {
+ sc_set_bit_at(mant, result->desc.mantissa_size + ROUNDING_BITS);
+ }
return result;
}