Raised This Month: $51 Target: $400
 12% 

Shifting and joining, general bitwise operation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Old 03-14-2015 , 17:57   Shifting and joining, general bitwise operation
Reply With Quote #1

So previously I asked about how to Capturing & Blocking Close Caption. Now on the other hand I have come to where I would like to send out a close caption message. However the shifting of bits confuses me and I have never been good at binary. Perhaps someone could give a hand here and explain exactly how I would send a new message out?

psychonic was kind enough last time to show me how to block and read the close caption data. The usermessage breaks down in to the following:

Quote:
Originally Posted by psychonic View Post
Neither. Int, 15-bit uint, 1-bit bool

Easiest way would probably be to read the last two together as a short, copy the least significant bit out as the last var and then shift the rest to the right. Multiply the duration by 10 to convert it to seconds.

Code:
new id = BfReadNum(bf); new temp = BfReadShort(bf); new bool:from_player = (temp & 1); new signed = (temp >> 1) & 0x7FFF; new unsigned = (signed < 0) ? signed + 0x10000 : signed; new Float:duration = float(unsigned);
If I were to turn that around and send a message out with it, how would I exactly do that?

Code:
new id = 1327396910 new bool:from_player = false new Float:duration = 15.0 new unsigned = RoundFloat(duration) new signed = ?
Mr. Zero is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode