Dealing with the bits of a floating point number directly is a bit odd, and it makes it hard to review the code. Is there a reason you don't want to use things like modf, floor, and ceil?