Home > Back-end >  * (float *) & I and (float) is the difference between the I?
* (float *) & I and (float) is the difference between the I?

Time:04-24

Uint32_t I=11;
cout <* (float *) & amp; I & lt; cout <(float) I & lt; The result is:
* (float *) & amp; Val: 1.54143 e-44
Val (float) : 11

Why is not the same as the two values is not very good. The first * (float *) & amp; I, I will address is converted into float *, out put value; Namely uint32_t data can be converted to a float, so why not directly (float) converts val?

CodePudding user response:

(float *) & amp; I, is the content that is stored in the memory I interpreted as float directly, because the format of the float and an int does not agree completely, so the error
(float) I, is to put the plastic to float, the compiler will automatically help you convert,

CodePudding user response:

There is a special case:
Float 0.0 f
And
Int 0
The same,

CodePudding user response:

1/f, said is very right, shaping and float memory allocation rules, you are so strong lu certainly disappear
  • Related