Project

General

Profile

Backport #3159

BigDecimal broken in 32bit Ruby

Added by DerGuteMoritz (Moritz Heidkamp) about 9 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
[ruby-core:29556]

Description

=begin
The following code:

require 'bigdecimal'
BigDecimal.new('100000000').div(BigDecimal.new('3'))

returns (as one would expect) 33333333 in 64bit Ruby (tested on NetBSD and Linux). In 32bit Ruby, however, it returns 33330000 (as one would probably not expect). This is true for 1.8.x as well as 1.9.x (tested on Linux and Mac OS X Slow Lepperd). Unfortunately, I can't provide a patch to fix this but maybe someone more proficient than me reads this and can look into it!
=end

Associated revisions

Revision b1809bcf
Added by yugui (Yuki Sonoda) about 9 years ago

merges r26626 and r26627 from trunk into ruby_1_9_1. This fixes #3159.

  • ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): fix precision. [ruby-core:17472][ruby-dev:35372][ruby-dev:40105][ruby-dev:40358] --
  • ext/bigdecimal/bigdecimal.c (BigDecimal_divide): fix precision too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@27597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

History

#1

Updated by rogerdpack (Roger Pack) about 9 years ago

=begin
Appears to work in 1.9.2:

191:
irb(main):003:0> BigDecimal.new('100000000').div(BigDecimal.new('3'))
=> 33330000

192:

irb(main):003:0> BigDecimal.new('100000000').div(BigDecimal.new('3'))
=> 33333333

=end

#2

Updated by yugui (Yuki Sonoda) about 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r27597.
Moritz, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Also available in: Atom PDF