| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Formulas 2.1. Representation of numbers</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 | Formulas 2.1. Representation of numbers |
| 13 | </b></font></table></table> |
| 14 | <p>Formulas can work with integer numbers as well as with real numbers.</p> |
| 15 | <h2>Real numbers</h2> |
| 16 | <p>You can type many real numbers by using a decimal notation, for instance 3.14159, 299792.5, or -0.000123456789. For very large or small numbers, you can use the <i>e</i>-notation: 6.022·10<sup>23</sup> is typed as <code><font size=+1>6.022e23</font></code> or <code><font size=+1>6.022e+23</font></code>, and -1.6021917·10<sup>-19</sup> is typed as <code><font size=+1>-1.6021917e-19</font></code>. You can use also use the percent notation: 0.157 can be typed as <code><font size=+1>15.7%</font></code>.</p> |
| 17 | <p>There are some limitations as to the values that real numbers can have in Praat. The numbers must lie between -10<sup>308</sup> and +10<sup>308</sup>. If you type</p> |
| 18 | <code> 1e200 * 1e100<br></code> |
| 19 | <p>the outcome will be</p> |
| 20 | <code> 1e+300<br></code> |
| 21 | <p>but if you type</p> |
| 22 | <code> 1e300 * 1e100<br></code> |
| 23 | <p>the outcome will be</p> |
| 24 | <code> --undefined--<br></code> |
| 25 | <p>Another limitation is that the smallest non-zero numbers lie near -10<sup>-308</sup> and +10<sup>-308</sup>. If you type</p> |
| 26 | <code> 1e-200 / 1e100<br></code> |
| 27 | <p>the outcome will be</p> |
| 28 | <code> 1e-300<br></code> |
| 29 | <p>but if you type</p> |
| 30 | <code> 1e-300 / 1e100<br></code> |
| 31 | <p>the outcome will be</p> |
| 32 | <code> 0<br></code> |
| 33 | <p>Finally, the precision of real numbers is limited by the number of bits that every real number is stored with in the computer, namely 64. For instance, if you type</p> |
| 34 | <code> pi<br></code> |
| 35 | <p>the outcome will be</p> |
| 36 | <code> 3.141592653589793<br></code> |
| 37 | <p>because only 16 digits of precision are stored. This can lead to unexpected results caused by rounding. For instance, the formula</p> |
| 38 | <code> 0.34999999999999999 - 0.35<br></code> |
| 39 | <p>will result in</p> |
| 40 | <code> 0<br></code> |
| 41 | <p>rather than the correct value of 1e-17. This is because the numbers 0.34999999999999999 and 0.35 cannot be distinguished in the computer's memory. If you simply type</p> |
| 42 | <code> 0.34999999999999999<br></code> |
| 43 | <p>the outcome will be</p> |
| 44 | <code> 0.35<br></code> |
| 45 | <p>(as in this example, the calculator will always come up with the minimum number of digits needed to represent the number unambiguously).</p> |
| 46 | <p>Another example of inaccuracy is the formula</p> |
| 47 | <code> 1 / 7 / 59 * 413<br></code> |
| 48 | <p>Because of rounding errors, the result will be</p> |
| 49 | <code> 0.9999999999999999<br></code> |
| 50 | <h2>Integer numbers</h2> |
| 51 | <p>Formulas can work with integer (whole) numbers between -1,000,000,000,000,000 and +1,000,000,000,000,000. You type them without commas and without the plus sign: 337, -848947328345289.</p> |
| 52 | <p>You <i>can</i> work with larger numbers than that (up to 10<sup>308</sup>), but there will again be rounding errors. For instance, the formula</p> |
| 53 | <code> 1000000000000000 + 1<br></code> |
| 54 | <p>correctly yields</p> |
| 55 | <code> 1000000000000001<br></code> |
| 56 | <p>but the formula</p> |
| 57 | <code> 10000000000000000 + 1<br></code> |
| 58 | <p>yields an incorrect outcome:</p> |
| 59 | <code> 1e16<br></code> |
| 60 | <h3>Links to this page</h3> |
| 61 | <ul> |
| 62 | <li><a href="Formulas.html">Formulas</a> |
| 63 | <li><a href="Formulas_2__Representations.html">Formulas 2. Representations</a> |
| 64 | </ul> |
| 65 | <hr> |
| 66 | <address> |
| 67 | <p>© ppgb 20170916</p> |
| 68 | </address> |
| 69 | </body> |
| 70 | </html> |