summaryrefslogtreecommitdiff
path: root/set_str.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-09-24 12:02:45 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-09-24 12:02:45 +0000
commit58cef36c22f5f9d05f526f39ec55d26f71101022 (patch)
tree713cb96eb314667d33b26fe62aa162c81be32592 /set_str.c
parent7eb7a9c19210d83f71fd20df04fe2a1754e3a129 (diff)
downloadmpfr-58cef36c22f5f9d05f526f39ec55d26f71101022.tar.gz
Accept (case-insensitive) NaN and Inf in input for bases <= 16 for
backward compatibility in these bases (for bases > 16, we cannot guaranty backward compatibility with the current wanted behavior). Added tests. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2443 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_str.c')
-rw-r--r--set_str.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/set_str.c b/set_str.c
index f463abc8c..ca02a7ae6 100644
--- a/set_str.c
+++ b/set_str.c
@@ -96,7 +96,8 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
if (base < 2 || base > 36)
return -1;
- if (strncasecmp (str, "@NaN@", 5) == 0)
+ if (strncasecmp (str, "@NaN@", 5) == 0 ||
+ (base <= 16 && strcasecmp (str, "NaN") == 0))
{
MPFR_SET_NAN(x);
/* MPFR_RET_NAN not used as the return value isn't a ternary value */
@@ -111,7 +112,8 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
/* be careful that 'inf' is a valid number in base >= 24,
since i=18, n=23, f=15 */
- if (strncasecmp (str, "@Inf@", 5) == 0)
+ if (strncasecmp (str, "@Inf@", 5) == 0 ||
+ (base <= 16 && strcasecmp (str, "Inf") == 0))
{
MPFR_CLEAR_NAN (x);
MPFR_SET_INF (x);