It converts a float number to scientific notation using the format
[sign] d.ddd e[sign]ddd
where d represents a digit, the digits before the decimal point represent the field width, and the digits after the decimal point represent the specified precision. Note that a number in this form is equivalent to
[sign] d.ddd x 10^([sign]ddd)
For example, when we use the format %15.4e, that is, field width = 15 and precision = 4, to display the number
123456789.12
in scientific notation, we get
bbbb1.2346e+009
(where b represents blank), which is equivalent to
1.2346 x 10^9
or
1234600000.0
On display, we lose some accuracy because the specified precision is not high enough. However, the affects the display only. The complete value still is stored in the computer's memory.
No comments:
Post a Comment