Rules FAQ Members List Search Register Login

 Raised This Month: \$106 Target: \$400 26%

Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
09-16-2021 , 01:18   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#91

Quote:
 Originally Posted by Bugsy Yes, the limiting factor is the number of bits in a 4-byte cell. HamletEagle, I think it's better to say each enum item is 1 bit.
So, how many items can I have then 50, 100, 200 ?
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 09-16-2021 , 01:23   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators #92 Google how many bits are in a byte, then multiply that value by 4. You can do extra coding to extend beyond this 'enum limit' if needed. __________________ Last edited by Bugsy; 09-16-2021 at 01:25.
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
09-16-2021 , 04:00   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#93

Quote:
 Originally Posted by Bugsy Google how many bits are in a byte, then multiply that value by 4. You can do extra coding to extend beyond this 'enum limit' if needed.
So the result is 32 assuming cell as an signed 4 byte integer.
As in C++ also the max we can go is 32 items.

And how do you plan to exceed that 32 limit ?
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 09-16-2021 , 09:59   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators #94 It's been covered before somewhere on the forums, but you'd need to create a macro or function to do this. Basically you'd use an array to get bits in excess of 32. So if you need 64 bits, you have an array bitField[ 2 ]. For bits 1-32 the first cell is used, for bits 33 to 64, the second cell is used, etc. __________________
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
09-16-2021 , 10:02   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#95

Quote:
 Originally Posted by Bugsy It's been covered before somewhere on the forums, but you'd need to create a macro or function to do this. Basically you'd use an array to get bits in excess of 32. So if you need 64 bits, you have an array bitField[ 2 ]. For bits 1-32 the first cell is used, for bits 33 to 64, the second cell is used, etc.
Any link or the way to do it would be usefull ...
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 09-16-2021 , 10:13   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators #96 Look here , post 49 and forward https://forums.alliedmods.net/showth...t=90507&page=2 __________________ Last edited by Bugsy; 09-16-2021 at 10:13.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
 09-16-2021 , 10:33   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators #97 Out of curiosity, what are you trying to do that requires you to have more than 32 flags? __________________
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
09-16-2021 , 21:56   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#98

Quote:
 Originally Posted by HamletEagle Out of curiosity, what are you trying to do that requires you to have more than 32 flags?
Out of curiosity I just created a mod which currently has 32 different round types. Maybe in future I will add more. That's why I asked and also for knowledge. Because I am also learning C and C++.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
09-16-2021 , 22:26   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#99

Quote:
 Originally Posted by Abhinash Out of curiosity I just created a mod which currently has 32 different round types. Maybe in future I will add more. That's why I asked and also for knowledge. Because I am also learning C and C++.
"round type" sounds like something that has mutually exclusive values (i.e. two or more round types cannot be active at the same time). If this is true, then you shouldn't be using bits for storing these values, you should use an integer-based enum.
__________________
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
09-19-2021 , 11:58   Re: [TUT] Bits, Bit-fields, and Bit-wise Operators
#100

Quote:
 Originally Posted by fysiks "round type" sounds like something that has mutually exclusive values (i.e. two or more round types cannot be active at the same time). If this is true, then you shouldn't be using bits for storing these values, you should use an integer-based enum.
Ofcourse not. Both of them are not active at the same time. Only one at a time. And that is also reset at the round end to g_roundtype = R_NONE where value of R_NONE in the left bit shifting enum is '0'.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 20:05.

 DMCA - Archive - Top