f = f + 0x1p23f - 0x1p23f;
For some reason, this will convert 2.6f
to 3f
.
float fun(float f) { float x = !(f < 0) ? f : -f; float y = !(x < 0x1p31f) ? x : (float)(int)x; return !(f < 0) ? y : -y; }
Why do you check for 0x1p31
rather than 0x1p23
?
Regarding pointer arithmetic, if I cast all the pointers to integers first, and then do the math, will it work? For some reason, I thought that casting to character pointer should always work, that's why I sad for non-char pointers in the OP.