Float bit manipulation?

Programming related discussions related to game research
mecha_yodzilla
Posts: 8
Joined: Mon Jan 04, 2021 4:58 pm

Float bit manipulation?

Post by mecha_yodzilla »

I've been going through the binary for a PS2 game, and really often the same thing comes up in the decompilation:

Code: Select all

if ((byte)((uint)) float_var >> 0x17) < 0x9e) {
   //some code
}


I cannot for the life of me figure out what this is trying to understand about any given float. Any insight would be much appreciated. If it helps, this has shown up around code I know is used for the rotation of the camera.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Float bit manipulation?

Post by aluigi »

In IEEE 754 that exact part of bits is the sign (1) plus the exponent (8) so I suppose that instruction simply checks if the float number is less or equal than the maximum positive 32bit signed integer (0x7fffffff.0).

Indeed 0x9e<<0x17 is just 2147483648.0, I hope I didn't miss anything :)
mecha_yodzilla
Posts: 8
Joined: Mon Jan 04, 2021 4:58 pm

Re: Float bit manipulation?

Post by mecha_yodzilla »

Thank you, that makes everything so much clearer!