self
, with scientific notationAdpat the number of decimals as needed from 1 to a maximum of 6
assert 12.34.to_sci == "1.234e+01"
assert 123.45.to_sci.to_f.to_sci == "1.2345e+02"
assert 0.001234.to_sci == "1.234e-03"
assert (inf).to_sci == "inf"
assert (nan).to_sci == "nan"
# Return the representation of `self`, with scientific notation
#
# Adpat the number of decimals as needed from 1 to a maximum of 6
# ~~~
# assert 12.34.to_sci == "1.234e+01"
# assert 123.45.to_sci.to_f.to_sci == "1.2345e+02"
# assert 0.001234.to_sci == "1.234e-03"
# assert (inf).to_sci == "inf"
# assert (nan).to_sci == "nan"
# ~~~
fun to_sci: String
do
var is_inf_or_nan = check_inf_or_nan
if is_inf_or_nan != null then return is_inf_or_nan
return adapt_number_of_decimal(return_from_specific_format("%e".to_cstring), true)
end
lib/core/text/abstract_text.nit:2042,2--2057,4