sprintf.c: fix condition
* sprintf.c (rb_str_format): fix condition to round. [ruby-core:64454] [Bug #10151] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f587347c28
commit
28dd61607e
@ -1,3 +1,8 @@
|
||||
Tue Aug 19 22:28:32 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* sprintf.c (rb_str_format): fix condition to round.
|
||||
[ruby-core:64454] [Bug #10151]
|
||||
|
||||
Tue Aug 19 22:22:45 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* enc/trans/euckr-tbl.rb (EUCKR_TO_UCS_TBL): add missing euro and
|
||||
|
@ -1045,7 +1045,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
|
||||
sign = -1;
|
||||
num = rb_funcallv(num, idUMinus, 0, 0);
|
||||
}
|
||||
if (den != INT2FIX(1) && prec > 1) {
|
||||
if (den != INT2FIX(1) || prec > 1) {
|
||||
const ID idDiv = rb_intern("div");
|
||||
VALUE p10 = rb_int_positive_pow(10, prec);
|
||||
VALUE den_2 = rb_funcall(den, idDiv, 1, INT2FIX(2));
|
||||
|
@ -151,6 +151,7 @@ class TestSprintf < Test::Unit::TestCase
|
||||
def test_rational
|
||||
assert_match(/\A0\.10+\z/, sprintf("%.60f", 0.1r))
|
||||
assert_match(/\A0\.3+\z/, sprintf("%.60f", 1/3r))
|
||||
assert_match(/\A1\.20+\z/, sprintf("%.60f", 1.2r))
|
||||
end
|
||||
|
||||
def test_hash
|
||||
|
Loading…
x
Reference in New Issue
Block a user