![]() |
#1 | ||||||||||||
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 700
|
![]()
Introduction
Last days I did some research regarding bit manipulation and extractions and ended up with this small, very useful include. This include will save you lots of memory if you use it efficient. Integer Limits
A higher/lower value will just repeat until the limit and start over again till done. Usage Declaration The syntax is quite simple. You just use BitX and replace X with the prefered bit type as tag, followed by the name and then the size between < and >. So for example let's declare a 4-bit array b4_Nibble with a size of 32: pawn Code:
You can use the BitX_Set/Get function for this. For example: pawn Code:
Retrieving the value is as simple as: pawn Code:
Examples Here are some simple examples of what I mean by "saving lots of memory". I often see people doing things like this: pawn Code:
pawn Code:
This is just analog all the rest of the bit-types, just make sure you pick the right bit-type for your value. Download rBits.inc FAQ
Last edited by RyDeR`; 24/02/2012 at 11:09 PM. |
||||||||||||
![]() |
![]() |
![]() |
#2 |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Jan 2010
Location: England
Posts: 2,084
Reputation: 163
|
![]()
Nice Ryder! I'd thought about this in the past, but aren't you leaving yourself open to possible overflows? (I haven't looked at the source code yet, so I'm probably wrong)
|
![]() |
![]() |
![]() |
#3 |
Big Clucker
![]() ![]() Join Date: Jun 2010
Posts: 105
Reputation: 0
|
![]()
Nice I will try it!
|
![]() |
![]() |
![]() |
#4 |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Posts: 4,513
Reputation: 398
|
![]()
Now I understand what bits are, thanks a lot for this.
So normal variables are 32bits? Which means they can store a high amount of data but we only need 0 and 1. Whenever we use a variable to just check something if it's true or false we simply use the 1bit array right? And when we count a variable we just use the 16bit? |
![]() |
![]() |
![]() |
#5 | ||
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 700
|
![]() Quote:
Yes. Quote:
No, you just use the value you need and nothing more. If you use 16-bit arrays, you can save a maximum amount of 65535 like I said in the topic (see limits). |
||
![]() |
![]() |
![]() |
#6 | |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Mar 2008
Posts: 4,513
Reputation: 398
|
![]() Quote:
(Which is the right thing I need) I'm switching right NOW!, Thanks again. Good job. |
|
![]() |
![]() |
![]() |
#7 |
Banned
![]() Join Date: May 2011
Location: Russia
Posts: 3,013
Reputation: 824
|
![]()
nice
![]() Last edited by Kaperstone; 10/08/2014 at 10:22 AM. |
![]() |
![]() |
![]() |
#8 |
Big Clucker
![]() ![]() Join Date: Jun 2011
Posts: 89
Reputation: 2
|
![]()
This is awesome i'm gonna use this
![]() |
![]() |
![]() |
![]() |
#9 |
High-roller
![]() ![]() ![]() ![]() ![]() Join Date: Feb 2009
Location: Belgium
Posts: 2,929
Reputation: 700
|
![]() |
![]() |
![]() |
![]() |
#10 |
Big Clucker
![]() ![]() Join Date: Jun 2011
Posts: 89
Reputation: 2
|
![]()
I mean he think on something like this
RandomEx(min, max) but that's posible and easy to make use 'Min, Max' fnc OFF TOPIC |
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Include] vDealer, probally the most simple vehicledealer system (Supports Y_INI & MYSQL!) Make your own vehicleshops in 1 line! | gamer931215 | Includes | 122 | 19/05/2014 03:54 PM |
TrueServe doesn't supports Hosted Tab? | Ouch_Charlie | General | 3 | 14/05/2011 03:30 PM |
[FilterScript] [FS] ezConverter - Now supports CreateVehicle! | Rzzr | Filterscripts | 13 | 16/03/2010 10:25 PM |
[DAntiCheat] Bye Bye cheaters ... (0.12, SUPPORTS ONLY 0.1b) | DracoBlue | Filterscripts | 261 | 20/10/2009 11:20 AM |