510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
# File 'lib/numerals/numeral.rb', line 510
def self.from_coefficient_scale(coefficient, scale, options={})
radix = options[:base] || options[:radix] || 10
if coefficient < 0
sign = -1
coefficient = -coefficient
else
sign = +1
end
digits = Digits[base: radix]
digits.value = coefficient
point = scale + digits.size
normalization = options[:normalize] || :exact
normalization = :approximate if options[:approximate]
Numeral[digits, base: radix, point: point, sign: sign, normalize: normalization]
end
|