ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax
It is currently Sat Aug 13, 2022 2:38 am

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Float bit manipulation?
PostPosted: Tue May 03, 2022 8:22 pm 

Joined: Mon Jan 04, 2021 4:58 pm
Posts: 8
I've been going through the binary for a PS2 game, and really often the same thing comes up in the decompilation:
Code:
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.


Top
   
PostPosted: Wed May 04, 2022 6:06 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 12982
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 :)


Top
   
PostPosted: Wed May 04, 2022 3:18 pm 

Joined: Mon Jan 04, 2021 4:58 pm
Posts: 8
Thank you, that makes everything so much clearer!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited