Skip to content

Commit 2e80322

Browse files
committed
Fixed BigDecimal#to_s 5F formatting issue.
1 parent 3a207a2 commit 2e80322

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Bug fixes:
4242
* Make `Array#concat` work with no or multiple arguments (#1519).
4343
* Fixed BigDecimal coerce initial argument using `to_str` (#1826).
4444
* Make `Enumerable#chunk` work without a block (#1518).
45+
* Fixed `BigDecimal#to_s` formatting issue (#1711).
4546

4647
Compatibility:
4748

lib/truffle/bigdecimal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def to_s(format = 'E')
242242

243243
format '%s%s.%s',
244244
prefix,
245-
add_spaces_to_s(before_dot, true, space_frequency),
245+
add_spaces_to_s(before_dot, false, space_frequency),
246246
add_spaces_to_s(after_dot, false, space_frequency)
247247
else
248248
format '%s0.%se%d',

spec/ruby/library/bigdecimal/to_s_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
str1 = '-123.45678 90123 45678 9'
4343
BigDecimal("-123.45678901234567890").to_s('5F').should == str1
44+
BigDecimal('1000010').to_s('5F').should == "10000 10.0"
4445
# trailing zeroes removed
4546
BigDecimal("1.00000000000").to_s('1F').should == "1.0"
4647
# 0 is treated as no spaces

0 commit comments

Comments
 (0)