summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sprintf.c b/sprintf.c
index 78438bf55b..1c60837e78 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -522,6 +522,10 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
bin_retry:
switch (TYPE(val)) {
case T_FLOAT:
+ if (FIXABLE((long)RFLOAT(val)->value)) {
+ val = LONG2FIX((long)RFLOAT(val)->value);
+ goto bin_retry;
+ }
val = rb_dbl2big(RFLOAT(val)->value);
if (FIXNUM_P(val)) goto bin_retry;
bignum = 1;