The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#11
|
||||
|
||||
OK, let's start at 0
Computers can only handle two signal states: Low and High (Voltage). This represents a Bit, eg. 0 or 1. All Numbers are constructed as a series of bits, for example 01101001. This is called the binary or dual system, in opposite to the decimal system we use for everyday calculations. As there are only 2 Values (0 and 1), the base for this is 2. How do we determine the value of a number in the decimal system: For eamle 126 is One Hundred and Twenytsix, or One Hundred + Tweny + Six, or formally: 6*10^0 + 2*10^2 + 1*10^2 This works the same way in dual system, but with 2 as base: 10000 = 0*2^0 + 0*2^1 + 0*2^2 + 0*2^3 + 0*2^4 = 16 As you can see, 16 represents the 5th bit. Now we got some decimal number, let's say 287654. How do we know if the 5th bit is set? First we convert this to a number in dual system by cintinued division: Code:
287654 / 2 = 143827 + 0 143827 / 2 = 71913 + 1 71913 / 2 = 35956 + 1 35956 / 2 = 17978 + 0 17978 / 2 = 8989 + 0 8989 / 2 = 4494 + 1 4494 / 2 = 2247 + 0 2247 / 2 = 1123 + 1 1123 / 2 = 561 + 1 561 / 2 = 280 + 1 280 / 2 = 140 + 0 140 / 2 = 70 + 0 70 / 2 = 35 + 0 35 / 2 = 17 + 1 17 / 2 = 8 + 1 8 / 2 = 4 + 0 4 / 2 = 2 + 0 2 / 2 = 1 + 0 1 / 2 = 0 + 1 Code:
1000110001110100110 Now we can check if bit #5 (decimal 16, dual 10000) is set: Code:
1000110001110100110 10000 Code:
1000110001110100110 & 10000 = 0000000000000000000 But if we had for example Code:
1000110001110110110 & 10000 = 0000000000000010000 What is the difference between 1000110001110100110 and 1000110001110110110? We already know that 1000110001110100110 is 287654 because we started with this. So let's convert 1000110001110110110 to decimal: 0*2^0 + 1*2^1 + 1*2^1 + 0*2^2 ... = 287670. As you can see, the difference is 16, as expected as this represents the bit we just set. Maybe this makes things a bit clearer - or got you totally confused |
#12
|
|||
|
|||
I know perfectly how numbers are represented and the decimal and binary coding systems.
This is the problem: after the first replies to this thread I understood that the binary string with all the on-off (0-1) settings was stored as an integer in mysql. PHP Code:
I suppose that the "WHERE options & 16" condition goes to check the bit #16 if is "ON" or "TRUE", or... 1! Am I wrong? The other posts (16 or not 16 :P ) confused me a bit... |
#13
|
||||
|
||||
Quote:
Maybe dozenzs of years in the future ... 65535 Bit-Systems ^.^ No. These are decimal values. WHERE options & 16 checks if Bit #5 (2^4=16) is set. |
#14
|
|||
|
|||
Quote:
I wasn't able to figure out the big numbers of the options field Perhaps do you know where can I find some documentation about the & operator? Thanks! Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|