Lots of conversions going on.

`int i1 = 0xdeadbeef; int i2 = 0xffffbeef`

incur *implementation defined* conversions as the constants are out of `int`

range. Here, they are "wrapped".

`i2`

is a small value (15 significant bits) exactly representable as a `float`

.

`i1`

is not. `i1`

has 30 significant bits, 6 more than the 24 of `float`

. Those lower 6 are not 0, so `(float) i1`

results is a *rounded* value.

```
int main() {
int i1 = 0xdeadbeef;
int i2 = 0xffffbeef;
printf("%d\n", (int) (float) i1 == i1);
printf("%d\n", (int) (float) i2 == i2);
printf("%u %10d %17f %10d\n", 0xdeadbeef, i1, (float) i1, (int) (float) i1);
printf("%u %10d %17f %10d\n", 0xffffbeef, i2, (float) i2, (int) (float) i2);
}
```

Output

```
0
1
3735928559 -559038737 -559038720.000000 -559038720
4294950639 -16657 -16657.000000 -16657
```

`int`

, because it's a signed type with 31 value bits only.`int`

is typically constrained to +/-2.1e9 and anything outside of those bounds is undefined behaviour. If these were`unsigned int`

or`uint32_t`

, then the values are valid, but you still have the problem with`float`

.`int i1 = 0xdeadbeef`

is not UB. Conversion "... result is implementation-defined or an implementation-defined signal is raised."2more comments