How it Works

How Values To Metric Prefixes Conversion Works

The scrip values_to_metric_prefixes converts decimal values to quantities with metric prefixes.  It is similar to the previous example program, but there are two main differences.  First, values_to_metric_prefixes is not using special formatting strings to ensure that the values display as decimal (instead of sometimes displaying exponential notation).  Second, this conversion is the inverse of the previous conversion.  In this script, the value-to-quantity conversion is done with division:

    quantity = value / (10 ** exponent)

In the previous example, the quantity to value conversion was done with multiplication:

    value = quantity * (10 ** exponent)

 

Try This

  • Try expanding the dictionary to include G, n and p, like in the previous example.

 


Did You Know...Scientific Notation?

Since 1 x 103 is 1000, it can also be used in place of the prefix k.  This same rule applies to all rows in the SI Metric Prefixes table on this page..  Just remember to use the rules of scientific notation in your calculations!

(View full size: muam-multiply-by-one-sci-note.mp4)


Your Turn