Exception to Number Format Exception with “D” and “F”?

匆匆过客 提交于 2019-12-01 15:17:33

some languages allow you to put letters after number literals to signify what type it is.

if you simply wrote 12.3, it might not know whether it is a float or a double(or it'd have to infer or cast it).

Your number parser must be picking up on these letters.

  • 12.3d is 12.3 as a double
  • 12.3f is 12.3 as a float

Java interprets numbers like 123f as referring to a float and 123d as a double, whereas plain 123 means an int.

Read the documentation on the number format supported by parseDouble. The f and d are instances of FloatTypeSuffix.

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