273.15
is a
double
value - so when you add it to a
float
value you get a
double
value (it always ends up with the "highest precision" type, so the
float
variable
celcius
is promoted to a
double
before the addition).
So when you try to store the result, you are storing a
double
value in a
float
variable, and the system is warning you that this could result in the loss of data.
The simplest fix is to use a
float
constant value instead by adding a "F" suffix:
float kelvin = celsius + 273.15f;