aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Kwan <dougkwan@google.com>2008-05-16 13:41:24 +0000
committerDiego Novillo <dnovillo@gcc.gnu.org>2008-05-16 09:41:24 -0400
commitf1f07a96da3b9d93b6fd2923aea88944a7ad55b5 (patch)
tree53e64ea80548c9626c93b624d83dfaf664a790d9
parent105f48aedd4222f499b663535684adddb5f2fcd8 (diff)
downloadgcc-f1f07a96da3b9d93b6fd2923aea88944a7ad55b5.zip
gcc-f1f07a96da3b9d93b6fd2923aea88944a7ad55b5.tar.gz
gcc-f1f07a96da3b9d93b6fd2923aea88944a7ad55b5.tar.bz2
real.c (real_to_decimal, [...]): Distinguish QNaN & SNaN.
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. From-SVN: r135421
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/real.c22
2 files changed, 26 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 93ff3b70..4f16907 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+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.
+
2008-05-16 Nathan Froyd <froydnj@codesourcery.com>
* doc/gty.texi (Source Files Containing Type Information): Note
diff --git a/gcc/real.c b/gcc/real.c
index ac3b7dc..c4695cc 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. */