bitwise and hexadecimal :S
Moderator: cheriff
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
bitwise and hexadecimal :S
hmm can anyone explain to me the bitwise operater?
eg: 0110 & 0011
0010
and can someone explain hexadecimal.. it scare's me 0-0
eg:
123 = 7 * 161 + B * 160 = 7B16
btw the 161.. the end 1 is a powerand the 0 on 160 and the 16 at the end :P
eg: 0110 & 0011
0010
and can someone explain hexadecimal.. it scare's me 0-0
eg:
123 = 7 * 161 + B * 160 = 7B16
btw the 161.. the end 1 is a powerand the 0 on 160 and the 16 at the end :P
ok the and operator compares each bits of the two arguments and then returns 1 if both bits are the same or 0 if they are not. easily explained using a table
A B O
0 0 0
1 0 0
0 1 0
1 1 1
so for your example
0110
0011
only the 2nd from the left bits are the same so output is 0010
hex is simple
Decimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 26 ... 32
Hex 1 2 3 4 5 6 7 8 9 A B C D E F 11 12 13 ... 1A ... 20
A B O
0 0 0
1 0 0
0 1 0
1 1 1
so for your example
0110
0011
only the 2nd from the left bits are the same so output is 0010
hex is simple
Decimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 26 ... 32
Hex 1 2 3 4 5 6 7 8 9 A B C D E F 11 12 13 ... 1A ... 20
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
Well, first, think of decimal.
10 is a 1 and a 0. It means add 1 ten and 0 ones...
(1 * ten) + (0 * one) = ten
24 is a 2 and a 4. It means add 2 tens and 4 ones...
(2 * 10) + (4 * 1) = twenty-four
321 is a 3, 2 and a 1. It means add 3 hundreds, 2 tens and 1 one...
(3 * 100) + (2 * 10) + (1 * 1) = three-hundred and twenty-one
Hexadecimal is just the same, but uses sixteen instead of ten. Because there are only 10 digits (0-9) we use A-E to represent values ten to fifteen.
10 is a 1 and a 0. It means add 1 sixteen and 0 ones...
(1 * sixteen) + (0 * one) = 16
24 is a 2 and a 4. It means add 2 sixteens and 4 ones...
(2 * 16) + (4 * 1) = 38
B0 is a B (11) and a 0. It means add 11 sixteens and 0 ones...
(11 * 16) + (0 * one) = 176
ABC is an A (10), a B (11) and a C (12). It means add 10 two-hundred and fifty-sixes, 11 sixteens and 12 ones...
(12 * 256) + (11 * 16) + (0 * 1) = 2748
10 is a 1 and a 0. It means add 1 ten and 0 ones...
(1 * ten) + (0 * one) = ten
24 is a 2 and a 4. It means add 2 tens and 4 ones...
(2 * 10) + (4 * 1) = twenty-four
321 is a 3, 2 and a 1. It means add 3 hundreds, 2 tens and 1 one...
(3 * 100) + (2 * 10) + (1 * 1) = three-hundred and twenty-one
Hexadecimal is just the same, but uses sixteen instead of ten. Because there are only 10 digits (0-9) we use A-E to represent values ten to fifteen.
10 is a 1 and a 0. It means add 1 sixteen and 0 ones...
(1 * sixteen) + (0 * one) = 16
24 is a 2 and a 4. It means add 2 sixteens and 4 ones...
(2 * 16) + (4 * 1) = 38
B0 is a B (11) and a 0. It means add 11 sixteens and 0 ones...
(11 * 16) + (0 * one) = 176
ABC is an A (10), a B (11) and a C (12). It means add 10 two-hundred and fifty-sixes, 11 sixteens and 12 ones...
(12 * 256) + (11 * 16) + (0 * 1) = 2748
Moved to offtopic, since this has nothing to do with PSP...
Shoot Pixels Not People!
Makeshift Development
Makeshift Development
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
dude hex is so simple! instead of us counting from 1-15 in decimal we count 1-F so it goes like
Decimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 26 ... 32
Hex----- 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 ... 1A ... 20
and when we get past F(15 in decimal) it changes to 10 we goe back to the start of the 0-F system just like when we get to 9 we carry the 1 over as our ten and then place the 0 for our units so 16 is 10 in hex 17 is 11, 25 is 19, 26 is 1A
google it if your still stuck
Decimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ... 26 ... 32
Hex----- 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 ... 1A ... 20
and when we get past F(15 in decimal) it changes to 10 we goe back to the start of the 0-F system just like when we get to 9 we carry the 1 over as our ten and then place the 0 for our units so 16 is 10 in hex 17 is 11, 25 is 19, 26 is 1A
google it if your still stuck
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
It's like Hundreds, Tens and Units you did at school when you were little. Except today the tops of the columns aren't hundreds, tens, and ones, they're 256s, 16s and 1s. So take your 7B and put it under those columns.
We've already said that A->F represent 10,11,12,13,14,15 so we have
B lots of 1 and 7 lots of 16
B*1 + 7*16
11 + 112
=123
Jim
Code: Select all
256 16 1
0 7 B
B lots of 1 and 7 lots of 16
B*1 + 7*16
11 + 112
=123
Jim
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
Just something additional, think of the carries you do when you add one.
In decimal, if I have 9 and add 1 to it, it becomes 0 carry 1 (or 0d10, which is 2 base10 numbers)
In binary, if I have 1 and I add 1, it becomes 0 carry 1, or (0b10, which is 2 base2 numbers)
In hexidecimal, if I have F and add 1, I get 0 carry 1, (or 0x10, which is 2 base16 numbers)
To add to johnso's rundown, think of binary:
0b10 is a 1 and a 0. It means add 1 two and 0 ones...
(1 * 2) + (1 * 0) = two
0b11 is a 1 and a 1. It means add 1 two and 1 ones...
(1 * 2) + (1 * 1) = three
0b100 is a 1, a 0 and a 0. It means add 1 four, 0 two and 0 ones...
(1 * 4) + (0 * 2) + (0 * 1) = four
0b1000000
(1 * 64) + (0 * 32) + (0 * 16) + (0 * 8) + (0 * 4) + (0 * 2) + (0 * 1) = ?? you figure it out...
also one more statement that I dont know if you have in your current level math: powers of two. You should see that all the numbers in the last example I gave you can be made by multiples of two
1 = 2^0 (2 to the power of 0)
2 = 2^1 (2)
4 = 2^2 (2x2)
8 = 2^3 (2x2x2)
16= 2^4 (2x2x2x2)
and this works the same for the others, base2 (binary), base8 (octal), base10 (decimal), base16 (hexidecimal)
In decimal, if I have 9 and add 1 to it, it becomes 0 carry 1 (or 0d10, which is 2 base10 numbers)
In binary, if I have 1 and I add 1, it becomes 0 carry 1, or (0b10, which is 2 base2 numbers)
In hexidecimal, if I have F and add 1, I get 0 carry 1, (or 0x10, which is 2 base16 numbers)
To add to johnso's rundown, think of binary:
0b10 is a 1 and a 0. It means add 1 two and 0 ones...
(1 * 2) + (1 * 0) = two
0b11 is a 1 and a 1. It means add 1 two and 1 ones...
(1 * 2) + (1 * 1) = three
0b100 is a 1, a 0 and a 0. It means add 1 four, 0 two and 0 ones...
(1 * 4) + (0 * 2) + (0 * 1) = four
0b1000000
(1 * 64) + (0 * 32) + (0 * 16) + (0 * 8) + (0 * 4) + (0 * 2) + (0 * 1) = ?? you figure it out...
also one more statement that I dont know if you have in your current level math: powers of two. You should see that all the numbers in the last example I gave you can be made by multiples of two
1 = 2^0 (2 to the power of 0)
2 = 2^1 (2)
4 = 2^2 (2x2)
8 = 2^3 (2x2x2)
16= 2^4 (2x2x2x2)
and this works the same for the others, base2 (binary), base8 (octal), base10 (decimal), base16 (hexidecimal)
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN
It looks to me like an 5 letter word; if so you'd convert them to hex and either look them up on a ascii table or put them into a hex editor to see what it would spell. When looking at something in a hex editor, 8 bits (8 ones and zeros = 2 hexidecimal characters) represent one character (or byte), since there are no operands (*/+-|~) and its split into 5 bytes....
It can't be ASCII, as the top bit is set for 4 of the bytes. ASCII is only 0 - 127 (0x0 to 0x7F in hex).cory1492 wrote:It looks to me like an 5 letter word; if so you'd convert them to hex and either look them up on a ascii table...
Look deep into their eyes for what they have to say, Emotions take control of life everyday
Death (Nothing Is Everything)
Death (Nothing Is Everything)
-
- Posts: 27
- Joined: Mon Feb 06, 2006 6:06 am
- Location: N.ireland LISBURN