65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/numerals/conversions/flt.rb', line 65
def write(number, exact_input, output_rounding)
output_base = output_rounding.base
input_base = @context.radix
if number.special?
special_num_to_numeral number
elsif exact_input
if output_base == input_base && output_rounding.free?
general_num_to_numeral number, output_rounding, false
else
exact_num_to_numeral number, output_rounding
end
else
if output_base == input_base && output_rounding.preserving?
Numeral.from_coefficient_scale(
number.sign*number.coefficient, number.integral_exponent,
approximate: true, base: output_base
)
elsif output_rounding.simplifying?
general_num_to_numeral number, output_rounding, false
else
general_num_to_numeral number, output_rounding, true
end
end
end
|