top of page

Scientific Notation

To save space and represent extremely large or small numbers we may opt to use scientific notation.

Let's say we want to print the number 278000000000000 but have limited space. We can instead print 2.78*10^14. To simplify this further we can simply set a variable to 2.78e14. For every number to the right of e the originating number on the left will shift the decimal place once.

Example:

Output:

scinotation2.png
scinotation1.png

The same can be done with smaller numbers like 0.000278 however we will use a negative number to the right of the e. This will instead move the decimal place to the left. 0.000278 translated into scientific notation gives us 2.78e-4.

Example:

Output:

scinotation4.png
scinotation3.png

To output a number in scientific notation we can use the %e format specifier. We will input a variable of type float and print it using %e.

Example:

Output:

scinotation6.png
scinotation5.png
  • Twitter
  • LinkedIn
  • discord-logo--v2
  • kisspng-github-pages-logo-repository-fork-github-logo-1-magentys-5b69de71b51265

Dragon Eye Intelligence LLC

bottom of page