Sha256: 85474e655f21bf20f059e19b455ff58e1a94cbeb763d136f3806f706ff74fd80
Contents?: true
Size: 512 Bytes
Versions: 1
Compression:
Stored size: 512 Bytes
Contents
module Precision class Calculator attr_accessor :decimal def initialize(decimal) @decimal = BigDecimal(String(decimal)) end def calculate return 0 if significant_digits == "0" [(significant_digits.length - exponent), 0].max end alias_method :to_i, :calculate private def significant_digits split[1] end def exponent split[3] end def split @split ||= decimal.split end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
precision-0.0.1 | lib/precision/calculator.rb |