If I have an extremely long floating point number in Ruby such as:
x = 123456789012345.to_f
when it is displayed, say, via to_s,
to_s
Just for convenience you can also control number of digits after decimal point. So do:
x = 1.234598 "%.3E" % x=> "1.235E+00"
Another neat thing you can do is pad with space from left like this:
x = 1.234 "%10.3E" % x => " 1.234E+00"