Skip to content

Instantly share code, notes, and snippets.

@vipulnsward
Created March 24, 2014 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vipulnsward/9736431 to your computer and use it in GitHub Desktop.
Save vipulnsward/9736431 to your computer and use it in GitHub Desktop.
require 'bigdecimal'
multiplier = Rational(1,10)
number = BigDecimal.new('1.1773748397827148')
(number / BigDecimal.new(multiplier.to_f.to_s)).round * multiplier
# Result -
# On MRI 2.1.1-
# (6/5) (Class - Rational)
# On JRuby- jruby-1.7.11
#<BigDecimal:1c7769f7,'0.0',1(4)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment