Sha256: 3cf82cfe3fa03ae18176266ec3b871ebd9d4110aade16bd772811f8095582f24
Contents?: true
Size: 315 Bytes
Versions: 1
Compression:
Stored size: 315 Bytes
Contents
module Stellar # reopen class class Price MAX_PRECISION = (2**31) - 1 def self.from_f(number) best_r = Util::ContinuedFraction.best_r(number, MAX_PRECISION) new({ n: best_r.numerator, d: best_r.denominator }) end def to_f n / d.to_f end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stellar-base-0.0.3 | lib/stellar/price.rb |