I have output like the following exponential numbers.
6.0e-07
8.1e-07
1.1e-09
But I want above numbers should be displayed like below
0.00000060
0.00000081
0.0000000011
I mean in the form decimal format. I surfed in the net. I could not find any solution for this.
Is it possible in ruby?. if yes How to do that?.
You could use BigDecimal#to_s:
require 'bigdecimal'
BigDecimal.new('6.0e-07').to_s('F') #=> "0.0000006"
BigDecimal.new('8.1e-07').to_s('F') #=> "0.00000081"
BigDecimal.new('1.1e-09').to_s('F') #=> "0.0000000011"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With