双字段类型声明为零 [英] double field type declaration as zero

查看:188
本文介绍了双字段类型声明为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下零双重变量声明之间有什么显着的区别:
0.0 VS 0d

What is significant difference between following zero double variable declaration: 0.0 VS 0d

double d1 = 0.0;
double d2 = 0d;

我知道这两个都比只是 0 ,因为对于代码阅读器来说更为明显。

I understand that both these are better than just 0,because are more obvious for code reader.

但是 0.0 VS 0d 差异对我来说不清楚。

However 0.0 VS 0d difference is not clear for me.

推荐答案

没有区别。看看 Java语言规范,第3.10.2节

There is no difference. Have a look at the Java Language Specification, section 3.10.2



DecimalFloatingPointLiteral:


  1. 数位。数位 opt ExponentPart opt FloatTypeSuffix opt

  2. 。数字ExponentPart opt FloatTypeSuffix opt

  3. 数字ExponentPart FloatTypeSuffix opt

  4. Digits ExponentPart opt FloatTypeSuffix

  1. Digits . Digitsopt ExponentPartopt FloatTypeSuffixopt
  2. . Digits ExponentPartopt FloatTypeSuffixopt
  3. Digits ExponentPart FloatTypeSuffixopt
  4. Digits ExponentPartopt FloatTypeSuffix


...


FloatTypeSuffix:

f F d D



都是一个 DecimalFloatingPointLiteral ,第一个类型1,第二个类型4

Both are a DecimalFloatingPointLiteral, the first one type 1, the second one type 4

这篇关于双字段类型声明为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆