Removing scientific notation from float

I am currently multiplying two floats: 0.0004 * 0.0000000000012 = 4.8e-16

How to get the result in a normal format, i.e. without scientific notation, something like 0.0000000000324, and then round it to 5 numbers.

+6
source share
1 answer

You can use string formatting .

a = 0.0004 * 0.0000000000012 # => 4.8e-16 '%.5f' % a # => "0.00000" pi = Math::PI # => 3.141592653589793 '%.5f' % pi # => "3.14159" 
+8
source

Source: https://habr.com/ru/post/913802/


All Articles