Revert part of #4225

Since in mruby, Integer and Float interchange frequently (mostly on
overflow), so adding explicit `.0` can cause problems sometimes.

For example:
https://github.com/mattn/mruby-json/pull/40
https://github.com/pepabo/mruby-msd/pull/13
https://github.com/mattn/mruby-json/pull/42
parent 8f04d656
...@@ -246,9 +246,6 @@ flo_to_s(mrb_state *mrb, mrb_value flt) ...@@ -246,9 +246,6 @@ flo_to_s(mrb_state *mrb, mrb_value flt)
str = mrb_float_to_str(mrb, flt, fmt); str = mrb_float_to_str(mrb, flt, fmt);
goto insert_dot_zero; goto insert_dot_zero;
} }
else {
mrb_str_cat(mrb, str, ".0", 2);
}
return str; return str;
} }
......
...@@ -212,10 +212,10 @@ assert('Float#to_s') do ...@@ -212,10 +212,10 @@ assert('Float#to_s') do
assert_equal("Infinity", Float::INFINITY.to_s) assert_equal("Infinity", Float::INFINITY.to_s)
assert_equal("-Infinity", (-Float::INFINITY).to_s) assert_equal("-Infinity", (-Float::INFINITY).to_s)
assert_equal("NaN", Float::NAN.to_s) assert_equal("NaN", Float::NAN.to_s)
assert_equal("0.0", 0.0.to_s) assert_equal("0", 0.0.to_s)
assert_equal("-0.0", -0.0.to_s) assert_equal("-0", -0.0.to_s)
assert_equal("-3.25", -3.25.to_s) assert_equal("-3.25", -3.25.to_s)
assert_equal("50.0", 50.0.to_s) assert_equal("50", 50.0.to_s)
assert_equal("0.0125", 0.0125.to_s) assert_equal("0.0125", 0.0125.to_s)
assert_equal("-0.0125", -0.0125.to_s) assert_equal("-0.0125", -0.0125.to_s)
assert_equal("1.0e-10", 0.0000000001.to_s) assert_equal("1.0e-10", 0.0000000001.to_s)
...@@ -224,8 +224,8 @@ assert('Float#to_s') do ...@@ -224,8 +224,8 @@ assert('Float#to_s') do
assert_equal("-1.0e+20", -1e20.to_s) assert_equal("-1.0e+20", -1e20.to_s)
assert_equal("1.0e+16", 10000000000000000.0.to_s) assert_equal("1.0e+16", 10000000000000000.0.to_s)
assert_equal("-1.0e+16", -10000000000000000.0.to_s) assert_equal("-1.0e+16", -10000000000000000.0.to_s)
assert_equal("100000.0", 100000.0.to_s) assert_equal("100000", 100000.0.to_s)
assert_equal("-100000.0", -100000.0.to_s) assert_equal("-100000", -100000.0.to_s)
if uses_float if uses_float
assert_equal("1.0e+08", 100000000.0.to_s) assert_equal("1.0e+08", 100000000.0.to_s)
assert_equal("-1.0e+08", -100000000.0.to_s) assert_equal("-1.0e+08", -100000000.0.to_s)
...@@ -234,8 +234,8 @@ assert('Float#to_s') do ...@@ -234,8 +234,8 @@ assert('Float#to_s') do
else else
assert_equal("1.0e+15", 1000000000000000.0.to_s) assert_equal("1.0e+15", 1000000000000000.0.to_s)
assert_equal("-1.0e+15", -1000000000000000.0.to_s) assert_equal("-1.0e+15", -1000000000000000.0.to_s)
assert_equal("100000000000000.0", 100000000000000.0.to_s) assert_equal("100000000000000", 100000000000000.0.to_s)
assert_equal("-100000000000000.0", -100000000000000.0.to_s) assert_equal("-100000000000000", -100000000000000.0.to_s)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment