java中的“Float a = 3f”和“Float a = 3.0”有什么区别? [英] what is the difference between 'Float a = 3f' and 'Float a = 3.0' in java?
本文介绍了java中的“Float a = 3f”和“Float a = 3.0”有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我执行
97346822*3f, result is 2.9204048E8,
然而
97346822*3.0 gives me 2.92040466E8.
请解释。
推荐答案
号码 3.0
是 double 值的htmlrel =noreferrer>字面表示(相当于 3.0d
),而 3.0f
是一个 float
值。不同的精确解释为什么你得到不同的结果 - 一个 double
使用64位存储,一个 float
使用32位。
The number 3.0
is the literal representation of a double
value (it's equivalent to 3.0d
), whereas 3.0f
is a float
value. The different precisions explain why you're getting different results - a double
is stored using 64-bits, a float
uses 32-bits.
这篇关于java中的“Float a = 3f”和“Float a = 3.0”有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文