java中1e9,1e-9或-1e9,哪一个是正确的?

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;

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?

Then the values would be between -1000000000 and 1000000000, right?

I am not sure what 1e-9 is meant for?

解决方案

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.)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值