String representations of floating point values may lead to incorrect conclusions about the precision of the values. For example, consider converting a value of type float
to the type double
, a widening primitive conversion. Refer to the guideline INT03-J. Do not cast Avoid casting numeric types to wider floating-point types without range checkingchecks for more details about such conversions. If the value of the float
variable must be represented exactly using the double
type, an explicit assignment is more appropriate than first converting the floating point value to a String
and then to a double
.
...