[英]3e5 in java for android
I work in javascript but I'm participating in a project for android. 我使用JavaScript工作,但我正在参与android项目。 I'm trying to write great numbers.
我正在尝试写大量数字。 In JS I'd write, for example 3e5 to get 300000. Is it the same in Java, I searched but I couldn't get an answer not using pow ^
在JS中,我会写例如3e5来得到300000。在Java中是否也一样,我进行了搜索,但未使用pow却无法得到答案^
In JS I'd write, for example 3e5 to get 300000
在JS中,我会写例如3e5得到300000
In java is almost (*) the same: 在Java中几乎(*)相同:
double x = 3e5;
float y = 3e5f;
This is for floating-point numbers, here is the complete spec for floating-point literals: JSL-3.10.2 这是浮点数的,这是浮点文字的完整规范: JSL-3.10.2
For integers this is not supported in java. 对于整数,java中不支持。 You can force a narrowing primitive conversion, but keep in mind you might lose precision:
您可以强制缩小原始的转换,但是请记住,您可能会失去精度:
int n = (int) 3e5;
(*) Footnote: I don't know JS, but it looks the same to me in this example. (*)脚注:我不懂JS,但是在这个例子中对我来说看起来一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.