cannot convert from double to float
Casting from a double to a float can be done like this:
double d = 1.2;
float f = (float) d;
Or if you just need to express 1.2
as a float to start with, then use 1.2f
.
Note
float
is single-precision 32-bit anddouble
is double-precision 64-bit so it is possible to lose precision in the conversion. See the primitive data types documentation.
What about this approach?
Float.valueOf(String.valueOf(your_double_variable));
Have you tried this?
float onerm = (float) (weigth/(1.0278-(.0278*reps)));