From 8dba5f4c900239d01897e2197ddd79bcf5d9b034 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Fri, 13 Jul 2018 13:56:10 +0300 Subject: Output +inf, +nan etc. also, so that output can be input. Doc, tests, fixed. --- node.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'node.c') diff --git a/node.c b/node.c index 984cec81..54ea6627 100644 --- a/node.c +++ b/node.c @@ -219,10 +219,13 @@ r_format_val(const char *format, int index, NODE *s) * < and > so that things work correctly on systems with 64 bit integers. */ - /* not an integral value, or out of range */ - if ((val = double_to_int(s->numbr)) != s->numbr + if (out_of_range(s)) { + const char *result = format_nan_inf(s, 'g'); + return make_string(result, strlen(result)); + } else if ((val = double_to_int(s->numbr)) != s->numbr || val <= LONG_MIN || val >= LONG_MAX ) { + /* not an integral value, or out of integer range */ /* * Once upon a time, we just blindly did this: * sprintf(sp, format, s->numbr); -- cgit v1.2.3