Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?

0
Posted

Some decimal values always print with exponential notation. Is there a way to get a non-exponential representation?

0

A. For some values, exponential notation is the only way to express the number of significant places in the coefficient. For example, expressing 5.0E+3 as 5000 keeps the value constant but cannot show the original’s two-place significance. If an application does not care about tracking significance, it is easy to remove the exponent and trailing zeroes, losing significance, but keeping the value unchanged: >>> def remove_exponent(d): … return d.quantize(Decimal(1)) if d == d.to_integral() else d.

0

A. For some values, exponential notation is the only way to express the number of significant places in the coefficient. For example, expressing 5.0E+3 as 5000 keeps the value constant but cannot show the original’s two-place significance.

Related Questions