Float in C changing value

Asked

Viewed 16 times

0

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?

inserir a descrição da imagem aqui

  • 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

  • 1

    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).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.