Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [AGK / DBP] Binary / Bit Flag Functions

Author
Message
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 24th Mar 2023 22:15 Edited at: 28th Mar 2023 23:34
While I'm almost certain these already exist on the forums., I can't actually find it as part of the Code Snippet/Samples forum.
It of course could be that I'm useless with search engines but it's weird to me that there isn't a code snipper with such.

This provides Bit (or Binary) Flagging Functions.
I need to test on Mobile, as I have a feeling that ARM uses Big Endian (reversed behaviour)... which is only specifically important if you're using these to comparison values (as you'll get the wrong numbers).
Still if you using it just for setting and getting individual bits; it will work just fine as then it doesn't matter about the order.



[edit]
Update • Changed how the Bits work ( 0 - 31 instead of 1 - 32 ) and added 4 new functions Set/GetByte (4x8bit) and Set/GetShort (2x16bit)
These should help when reading files that have 8bit and 16bit values

Update 2 • Added CreateIntegerFromBytes( ) and CreateIntegerFromShorts( )

Update 3 • Added Set/GetBitRange( ) for Custom Packing Data
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Mar 2023 23:59
Nice. I always have trouble with those

Login to post a reply

Server time is: 2024-04-24 06:12:22
Your offset time is: 2024-04-24 06:12:22