summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorh2so5 <[email protected]>2014-02-24 08:21:10 +0900
committerh2so5 <[email protected]>2014-02-24 08:21:10 +0900
commitf025e4961d1f53836abbf22fdf17b6a1b9cee270 (patch)
tree834b6b2ff4443ff508b61df32e15a1c3f482c666 /src
parent109f675f44ad0b03d8201d6d890c109f1529fd2b (diff)
downloadmruby-f025e4961d1f53836abbf22fdf17b6a1b9cee270.tar.gz
mruby-f025e4961d1f53836abbf22fdf17b6a1b9cee270.zip
limit preserved significand length
Diffstat (limited to 'src')
-rw-r--r--src/numeric.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c
index ec7f05b97..d09213235 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -19,9 +19,11 @@
#define ceil(f) ceilf(f)
#define fmod(x,y) fmodf(x,y)
#define FLO_MAX_DIGITS 7
+#define FLO_MAX_SIGN_LENGTH 3
#define FLO_EPSILON FLT_EPSILON
#else
#define FLO_MAX_DIGITS 14
+#define FLO_MAX_SIGN_LENGTH 10
#define FLO_EPSILON DBL_EPSILON
#endif
@@ -159,6 +161,7 @@ mrb_flo_to_str(mrb_state *mrb, mrb_value flo)
}
}
if (beg >= 0) length = end - beg;
+ if (length > FLO_MAX_SIGN_LENGTH) length = FLO_MAX_SIGN_LENGTH;
}
if (abs(exp) + length >= FLO_MAX_DIGITS) {