summaryrefslogtreecommitdiff
path: root/gcc/real.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-16 13:41:24 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-16 13:41:24 +0000
commitaf6cf582ab31d98c61020c753edac5b09860d984 (patch)
tree53e64ea80548c9626c93b624d83dfaf664a790d9 /gcc/real.c
parent76ee6ef25ed246ce903c8a9bd5448d73992a103f (diff)
downloadgcc-af6cf582ab31d98c61020c753edac5b09860d984.tar.gz
2008-05-16 Doug Kwan <dougkwan@google.com>
* real.c (real_to_decimal, real_to_hexadecimal): Distinguish QNaN & SNaN. (real_from_string): Handle NaNs and Inf as approriate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135421 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/real.c')
-rw-r--r--gcc/real.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/real.c b/gcc/real.c
index ac3b7dc02ec..c4695cced91 100644
--- a/gcc/real.c
+++ b/gcc/real.c
@@ -1471,7 +1471,8 @@ real_to_decimal (char *str, const REAL_VALUE_TYPE *r_orig, size_t buf_size,
return;
case rvc_nan:
/* ??? Print the significand as well, if not canonical? */
- strcpy (str, (r.sign ? "-NaN" : "+NaN"));
+ sprintf (str, "%c%cNaN", (r_orig->sign ? '-' : '+'),
+ (r_orig->signalling ? 'S' : 'Q'));
return;
default:
gcc_unreachable ();
@@ -1743,7 +1744,8 @@ real_to_hexadecimal (char *str, const REAL_VALUE_TYPE *r, size_t buf_size,
return;
case rvc_nan:
/* ??? Print the significand as well, if not canonical? */
- strcpy (str, (r->sign ? "-NaN" : "+NaN"));
+ sprintf (str, "%c%cNaN", (r->sign ? '-' : '+'),
+ (r->signalling ? 'S' : 'Q'));
return;
default:
gcc_unreachable ();
@@ -1812,6 +1814,22 @@ real_from_string (REAL_VALUE_TYPE *r, const char *str)
else if (*str == '+')
str++;
+ if (!strncmp (str, "QNaN", 4))
+ {
+ get_canonical_qnan (r, sign);
+ return 0;
+ }
+ else if (!strncmp (str, "SNaN", 4))
+ {
+ get_canonical_snan (r, sign);
+ return 0;
+ }
+ else if (!strncmp (str, "Inf", 3))
+ {
+ get_inf (r, sign);
+ return 0;
+ }
+
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
{
/* Hexadecimal floating point. */