summaryrefslogtreecommitdiff
path: root/print_raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'print_raw.c')
-rw-r--r--print_raw.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/print_raw.c b/print_raw.c
index afc2590d6..2e0fa907e 100644
--- a/print_raw.c
+++ b/print_raw.c
@@ -38,17 +38,20 @@ mpfr_print_raw(mpfr_srcptr x)
{
char *str;
- /* 3 char for sign + 0 + binary point
- + ABSSIZE(x) * BITS_PER_MP_LIMB for mantissa
- + 2 for brackets in mantissa
- + 1 for 'E'
- + 11 for exponent (including sign)
- = 17 + ABSSIZE(x) * BITS_PER_MP_LIMB
- */
- str = (char *) malloc((17 + ABSSIZE(x) * BITS_PER_MP_LIMB)*sizeof(char));
- mpfr_get_str_raw(str, x);
+ if (FLAG_NAN(x)) printf("NaN");
+ else {
+ /* 3 char for sign + 0 + binary point
+ + ABSSIZE(x) * BITS_PER_MP_LIMB for mantissa
+ + 2 for brackets in mantissa
+ + 1 for 'E'
+ + 11 for exponent (including sign)
+ = 17 + ABSSIZE(x) * BITS_PER_MP_LIMB
+ */
+ str = (char *) malloc((17 + ABSSIZE(x) * BITS_PER_MP_LIMB)*sizeof(char));
+ mpfr_get_str_raw(str, x);
- printf("%s", str);
- free(str);
+ printf("%s", str);
+ free(str);
+ }
}