I’m having a problem when declaring a variable float and assigning a value, this assigned value is changed in the execution of 273.15 it gets 273.149994 need it to continue as 273.15 someone has idea what’s going on?
Please clarify your specific problem or provide Additional Details to Highlight Exactly what you need. As it’s Currently Written, it’s hard to Tell Exactly what you’re asking.
This value cannot be represented exactly in floating point. It is a floating point trick. You treat this in the presentation, ie when it displays with 2 or 3 decimal places, round. If you PRECISE of an exact representation, as would be the case for a system that handles monetary values, must use an integer and scale (e.g. represent the temperature by 27315 and insert the decimal only at the time d display to the user).
Please clarify your specific problem or provide Additional Details to Highlight Exactly what you need. As it’s Currently Written, it’s hard to Tell Exactly what you’re asking.
–
https://answall.com/q/219211/101
– Maniero
This value cannot be represented exactly in floating point. It is a floating point trick. You treat this in the presentation, ie when it displays with 2 or 3 decimal places, round. If you PRECISE of an exact representation, as would be the case for a system that handles monetary values, must use an integer and scale (e.g. represent the temperature by 27315 and insert the decimal only at the time d display to the user).
– epx