1e-9或-1e9,哪一个是正确的? [英] 1e-9 or -1e9, which one is correct?
问题描述
我分配了一些旧代码,当我阅读它时,我注意到它有以下形式:
I am assigned some old code and when I was reading through it, I noticed it had these in the form of:
float low = 1e-9;
float high = 1e9;
float lowB = 1e-9;
float highB = 1e9;
float lowL = 1e-9;
float highL = 1e9;
所以我看到它试图使用e符号定义一些范围,对吗?但不是 1e-9
应该是 -1e9
?
So I see that it's trying to define some ranges using the e notation, right? But isn't 1e-9
supposed to be -1e9
?
那么值将在 -1000000000
和 1000000000
之间,对吗?
Then the values would be between -1000000000
and 1000000000
, right?
我不确定 1e-9
是用于?
推荐答案
两者都不比其他更正确。它们只代表不同的值。
Neither is more correct than the other. They just represent different values.
1e-9
是 0.000000001
;
-1e9
是 -1000000000.0
;
e
(或 E
)表示乘以10到,因此 1e9
是十分之一到九次方, 1e -9
表示负十次幂的1/10。在数学科学记数法中,这通常由上标表示:1×10 -9 或-1×10 9 。编程语言采用 e
或 E
符号,因为它比上标更容易打字和打印对于这个问题)。 (我认为这可能是Fortran在20世纪50年代,但我不知道确切的历史。)
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.)
这篇关于1e-9或-1e9,哪一个是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!