What is 1e-9?

def compare_floats(a, b, epsilon=1e-9): //判斷浮點數是否相等, 實際是判斷兩數相差是否大於那個極微小的數
    return abs(a - b) < epsilon

result = compare_floats(0.1 + 0.2, 0.3)  //現在返回True,正常工作!

 

 
Profile photo for Dylan Wood
 
 
Dylan Wood
 · 
Follow

It’s a way to write the number .000000001 in scientific notation, i.e., 1 × 10⁻⁹. The “e” is a more compact way to write “× 10^”.

Or in plain English, the “e” here means “times ten raised to the power of”, so 1e-9 can be read in the same way as 1 × 10⁻⁹, “one times ten raised to the power of negative nine”.

This is alternatively referred to as “E-notation”, and it is mostly used as a way to concisely write numbers in scientific notation, so that they are easier to read in text, or where space is limited, like on a calculator display.

Incidentally, the number 1e-9 corresponds to the scientific prefix nano and what is commonly referred to as the “nanoscale”. For example, a nanometer is one-billionth of a meter, or .000000001 meter or more concisely 1e-9 meter.

These are the sorts of length scales on which the field of nanotechnology works.

Scientific notation and metric affixes

You can enter metric affixes or scientific notation to indicate very large or very small numbers. For scientific notation, you can type either a caret (^) or the letter e followed by a number to indicate an exponent. You can use both positive and negative exponents.

For example, to indicate 0.012, you can enter either of the following expressions:

  • 1.2*10^-2
  • 1.2e-2

To indicate -440,000, you can enter either of the following expressions:

  • -4.4*10^5
  • -4.4e5

The following table shows how to enter numbers with metric affixes, with scientific notation, and with e notation.

To enter
this number 

Use this
metric affix

Scientific Notation

Use this
E Notation

Other Notation
0.1 1d (deci) 10^-1 1e-1  
0.01 1c (centi) 10^-2 1e-2 1% (percent)
0.001 1m (milli) 10^-3 1e-3  
0.000001 1u (micro) 10^-6 1e-6  
0.000000001 1n (nano) 10^-9 1e-9  
0.000000000001 1p (pico) 10^-12 1e-12  
1,000 1k (kilo) 10^3 1e3  
1,000,000 1M (mega) 10^6 1e6  
1,000,000,000 1G (giga) 10^9 1e9  
1,000,000,000,000  1T (tera) 10^12 1e12  

Note: When you use metric affixes or e notation, make sure you do not include spaces between the number and the metric affix or the e.

For more information, see Entering math expressions in assignments or the calculator or Using constants in math expressions.


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章