https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112020-11-21T11:23:54ZRuby Issue Tracking SystemRuby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886702020-11-21T11:23:54Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Subject</strong> changed from <i>Semantic grouping on BigDecimal#to_s</i> to <i>Semantic grouping with BigDecimal#to_s</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/88670/diff?detail_id=58357">diff</a>)</li></ul> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886722020-11-21T12:18:25Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Its document states:</p>
<blockquote>
<p>If s contains a number, a space is inserted after each group of that many fractional digits.</p>
</blockquote>
<p>If this is correct, grouping the integer part seems unintentional.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886752020-11-21T13:10:20Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>Shouldn't <code>BigDecimal('1234567').to_s('3F')</code> return <code>"1 234 567.0"</code> (without spaces at the beginning and just before the decimal dot), but not <code>" 1 234 567 .0"</code>, right?</p>
<p>We should consider this statement says nothing about the integer part, I guess now.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886782020-11-21T15:25:25Zchumaltd (Takahiro Chuma)
<ul></ul><p>nobu (Nobuyoshi Nakada) wrote in <a href="#note-3">#note-3</a>:</p>
<blockquote>
<p>Shouldn't <code>BigDecimal('1234567').to_s('3F')</code> return <code>"1 234 567.0"</code> (without spaces at the beginning and just before the decimal dot), but not <code>" 1 234 567 .0"</code>, right?</p>
<p>We should consider this statement says nothing about the integer part, I guess now.</p>
</blockquote>
<p>Thank you for discussion.</p>
<p>Yes, I mean "1 234 567.0" without heading space. It's just a mistake.<br>
<code>to_s</code> may not be changed for consistency. Some new method will be ok.</p>
<p>I just couldn't remind "123 456 7.890 12" use case.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886792020-11-21T15:29:56Zchumaltd (Takahiro Chuma)
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/88679/diff?detail_id=58358">diff</a>)</li></ul> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=886812020-11-22T09:28:47Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p><a href="https://github.com/ruby/ruby/compare/master...nobu:bug/17339-BigDecimal%23to_s-grouping?expand=1" class="external">https://github.com/ruby/ruby/compare/master...nobu:bug/17339-BigDecimal%23to_s-grouping?expand=1</a></p>
<p>Improves (especially for the doc) are welcome.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=887062020-11-24T04:24:46Zchumaltd (Takahiro Chuma)
<ul></ul><p>I read doc again, and understand the situation.</p>
<p>If we have a chance to change API, another formatting option like <code>#to_s('G')</code> can be good that works as '3F'.<br>
Then we'll have beautiful 'E', 'F', 'G' options.</p>
<p>As I referred, SI confirmed 3 digit grouping policy twice(1948 and 2003). Other than 3 is not preferred way.<br>
I think financial or business common practices follow 3 digit rule, too.</p>
<p>So, grouping option should have its default, and formatting with digit like '5F' will be more private.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=892952020-12-18T14:37:44Zmrkn (Kenta Murata)muraken@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>mrkn (Kenta Murata)</i></li></ul> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=954402021-12-20T12:38:30Zmrkn (Kenta Murata)muraken@gmail.com
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/18410">Feature #18410</a>: Proposal to make inspect include underscores on numerics</i> added</li></ul> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=954422021-12-20T12:39:17Zmrkn (Kenta Murata)muraken@gmail.com
<ul></ul><p>I will follow the consequence of <a class="issue tracker-2 status-1 priority-4 priority-default" title="Feature: Proposal to make inspect include underscores on numerics (Open)" href="https://bugs.ruby-lang.org/issues/18410">#18410</a>.</p> Ruby master - Feature #17339: Semantic grouping with BigDecimal#to_shttps://bugs.ruby-lang.org/issues/17339?journal_id=1037362023-07-01T15:02:17Zcryptogopher (crypto gopher)
<ul></ul><p>I've sent pull request with solution as specified by author of issue: <a href="https://github.com/ruby/bigdecimal/pull/264" class="external">https://github.com/ruby/bigdecimal/pull/264</a></p>