+ 1

Why should I add cast to a float in Java?

I can simply write it like others https://code.sololearn.com/cJqVD01HQ5w1/?ref=app

24th Sep 2020, 6:14 AM
Fawzi Elkhoury
Fawzi Elkhoury - avatar
2 Respostas
+ 8
Declaring float will result in loss of precision.so,java needs you to do the cast to make a float variable by declaration. By default, java compiler perceives as being a double 64 bits and not as a float 32 bits.
24th Sep 2020, 6:31 AM
chaithra Gowda
chaithra Gowda - avatar
+ 1
24th Sep 2020, 6:35 AM
Fawzi Elkhoury
Fawzi Elkhoury - avatar