From: nobu@... Date: 2014-08-19T13:28:41+00:00 Subject: [ruby-core:64459] [ruby-trunk - Bug #10151] [Closed] Weird result when % formatting a Rational value Issue #10151 has been updated by Nobuyoshi Nakada. Status changed from Open to Closed % Done changed from 0 to 100 Applied in changeset r47222. ---------- sprintf.c: fix condition * sprintf.c (rb_str_format): fix condition to round. [ruby-core:64454] [Bug #10151] ---------------------------------------- Bug #10151: Weird result when % formatting a Rational value https://bugs.ruby-lang.org/issues/10151#change-48408 * Author: Akira Matsuda * Status: Closed * Priority: Normal * Assignee: Kenta Murata * Category: core * Target version: current: 2.2.0 * ruby -v: ruby 2.2.0dev (2014-08-19 trunk 47220) [x86_64-darwin13] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- Getting a strange output when formatting a Rational value in trunk. % ruby -v -e 'p "%.1f" % 1.2r' ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] "1.2" % ruby -v -e 'p "%.1f" % 1.2r' ruby 2.2.0dev (2014-08-19 trunk 47220) [x86_64-darwin13] "6.0" In this case 1.2r inspects into 6/5 and then the % takes its first letter, I guess? -- https://bugs.ruby-lang.org/