Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java/Android - setting float values - 0f vs 0.0f

Tags:

java

android

I've been browsing through some Android source code and I noticed they set float values to 0 using 0.0f. I know that just 0 is an int that is then implicitly converted to float and that 0.0 is a double, but to my knowledge 0f is the same as 0.0f. Why would they go through the effort to type the extra .0 ? :)

like image 817
0ne_Up Avatar asked Jul 27 '15 09:07

0ne_Up


1 Answers

There's no reason other than style. 0f and 0.0f are identical values. Details in JLS§3.10.2.

like image 147
T.J. Crowder Avatar answered Oct 07 '22 23:10

T.J. Crowder