1e-9 or -1e9, which one is correct? [closed]

匆匆过客 提交于 2019-12-02 21:59:35

Neither is more correct than the other. They just represent different values.

1e-9 is 0.000000001; the minus sign applies to the exponent.

-1e9 is -1000000000.0; the minus sign applies to the number itself.

The e (or E) means "times 10-to-the", so 1e9 is "one times ten to the ninth power", and 1e-9 means "one times ten to the negative ninth power". In mathematical scientific notation, this is usually denoted by a superscript: 1 × 10-9 or -1 × 109. Programming languages adopted the e or E notation because it was easier to type and print than a superscript (and still is, for that matter). (I think this may have been introduced by Fortran in the 1950s, but I'm not sure of the exact history.)

"Low" and "high" refer to absolute values. The low number is small in absolute values, the high one is large. Negatives aren't important, since you already understand how to work with those. What's important about floats is their variable scale (i.e. the exponent), and so it is customary to provide lower and upper bounds for the scale rather than the value.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!