Skip to content

Instantly share code, notes, and snippets.

@ledermann
Last active August 29, 2015 13:56
Show Gist options
  • Save ledermann/8800404 to your computer and use it in GitHub Desktop.
Save ledermann/8800404 to your computer and use it in GitHub Desktop.
Dividing with BigDecimal - Ruby 1.9.3 vs. Ruby 2.1.0
# Using Ruby 1.9.3 on OS X, installed via rbenv
~ $ irb
irb(main):001:0> require "bigdecimal"
true
irb(main):002:0> BigDecimal("0.2") / BigDecimal("0.5")
0.4
# Using Ruby 2.1.0 on OS X, installed via rbenv
~ $ irb
irb(main):001:0> require "bigdecimal"
true
irb(main):002:0> BigDecimal("0.2") / BigDecimal("0.5")
0.0
# Using Ruby 2.1.0 with bigdecimal v1.2.5
~ $ irb
irb(main):001:0> gem "bigdecimal", "=1.2.5"
true
irb(main):002:0> require "bigdecimal"
true
irb(main):003:0> BigDecimal("0.2") / BigDecimal("0.5")
0.4
@ledermann
Copy link
Author

Solution: Gem "bigdecimal" <= v1.2.3 is broken, bug is fixed in v1.2.4
https://www.ruby-forum.com/topic/4419577

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment