Project

General

Profile

Actions

Bug #10850

closed

BigDecimal division incorrect

Added by Elyasin (Elyasin Shaladi) about 9 years ago. Updated almost 9 years ago.

Status:
Rejected
Assignee:
Target version:
-
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
[ruby-core:68108]

Description

I tried this in Ruby 2.1.4, 2.1.5 and 2.2.0, but in none of the versions it seems correct to me.

irb(main):041:0* amount1 = BigDecimal("241.3")
=> #BigDecimal:7f49bcb03558,'0.2413E3',18(18)

irb(main):042:0> amount2 = BigDecimal("1800")
=> #BigDecimal:7f49bcaf3400,'0.18E4',9(18)

irb(main):043:0> rate = amount1 / amount2
=> #<BigDecimal:7f49bcae8398,'0.1340555555 5555555555 5555556E0',27(45)>

irb(main):044:0> rate * amount2 #should return amount1 = 241.3 in BigDecimal, but it does not
=> #<BigDecimal:7f49bcad6a30,'0.2413000000 0000000000 00000008E3',36(45)>

My guess is that there is a bug in the BigDecimal implementation.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0