When you add two floating-point numbers, conceptually speaking they have to be shifted to line up their radix points with each other before you can add. The number (1 << 23) is a 1 followed by 23 bits of zero, so as a float its radix point lies at the very end of its mantissa, and its mantissa is all zeros (the 1 being implied). When you add flt to it, flt is first shifted so that its radix point lies at the same place. Thus the fractional part of flt falls off the end of the mantissa and the integer part is all that is left. Do the add, and you wind up with the integer part of flt in the mantissa field, at least up to rounding.

If you want truncation you may be able to switch to round-toward-zero mode (google for floating point rounding modes). Or, if your numbers are all positive, an easy trick is to subtract 0.5 before you round it.

Hi, does anyone know, why this is the case:

I would be greatful if somebody provides some info on the matter, how this great magic works!

edit: No, sorry, the code seems to perform a nearest rounding.