Page 1 of 2

bitwise and hexadecimal :S

Posted: Mon Apr 24, 2006 6:14 am
by Paradox.psp
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

Posted: Mon Apr 24, 2006 6:52 am
by JorDy
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

Posted: Mon Apr 24, 2006 6:56 am
by Paradox.psp
ok i got the hang of bitwise noew but the hex thingy lol how the hell does it make up 7B with a small 16?

Posted: Mon Apr 24, 2006 7:55 am
by johnsto
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

Posted: Mon Apr 24, 2006 2:47 pm
by dot_blank
fix: 0-9 == zero thru nine
A-F == ten thru fifteen

zero (0) is a value so its sixteen values for HEX
0 1 2 3 4 5 6 7 8 9 A B C D E F

TIP: now figure my signature ;)

Posted: Mon Apr 24, 2006 3:58 pm
by Drakonite
Moved to offtopic, since this has nothing to do with PSP...

Posted: Mon Apr 24, 2006 8:09 pm
by Paradox.psp
all i get is

10011011
00101010
11010111
10001001
10111010

00010001

Posted: Tue Apr 25, 2006 2:42 am
by JorDy
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

Posted: Tue Apr 25, 2006 5:07 am
by Paradox.psp
its hard to understand when ur only 13 ^_^

ok so what is 7b16 in just decimal?

Posted: Tue Apr 25, 2006 9:12 am
by Jim
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.

Code: Select all

256 16 1
  0  7 B
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

Posted: Tue Apr 25, 2006 9:58 am
by jimparis
The notation 7B16 just indicates that it's written in base 16. Typically in computer science we prefer to write "7Bh" or "0x7B" instead.

Posted: Wed Apr 26, 2006 2:16 am
by Paradox.psp
ok i think am getting the hang of it .. :D ty all expcally the ones with a really big post 0_0

Posted: Wed Apr 26, 2006 1:46 pm
by dot_blank
Paradox.psp wrote:all i get is

10011011
00101010
11010111
10001001
10111010

00010001
incorrect

Posted: Thu Apr 27, 2006 3:46 am
by Paradox.psp
how about 00000000

Posted: Thu Apr 27, 2006 4:27 am
by dot_blank
Paradox.psp wrote:how about 00000000
incorrect
hint: try binary ;)

Posted: Thu Apr 27, 2006 4:31 am
by Paradox.psp
binary? lol

Posted: Thu Apr 27, 2006 11:46 am
by Orfax
As they say, there are only 10 types of people in this world. Those that understand binary and those that don't. :)

Posted: Thu Apr 27, 2006 6:34 pm
by Viper8896
Orfax wrote:As they say, there are only 10 types of people in this world. Those that understand binary and those that don't. :)
lol 10 types :)

Posted: Fri Apr 28, 2006 12:44 am
by Paradox.psp
what is it?

Posted: Fri Apr 28, 2006 12:10 pm
by Viper8896
Paradox.psp wrote:what is it?
10 binary not ten decimal

10 binary = 2 decimal

Posted: Sat Apr 29, 2006 12:30 am
by Paradox.psp
the answer! :D

Posted: Sat Apr 29, 2006 1:30 am
by dot_blank
Paradox.psp wrote:the answer! :D
incorrect

Posted: Sat Apr 29, 2006 1:54 am
by Paradox.psp
telll me it!! ... how can u use binary? i need answer!

Posted: Tue May 02, 2006 1:05 am
by cory1492
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)

Posted: Tue May 02, 2006 5:23 am
by Paradox.psp
ok that was a big help.. i think i know but the way his question is layed out.. do i work them out and add them up?

Posted: Tue May 02, 2006 9:35 pm
by cory1492
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....

Posted: Wed May 03, 2006 8:05 am
by Orfax
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...
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).

Posted: Mon May 08, 2006 5:11 am
by cory1492
Gotcha, I think somewhere along the line I forgot that ASCII isnt only a subset of a larger whole... at any rate when I used the method with a hex editor I got gibberish/symbols.

Posted: Mon May 08, 2006 5:48 am
by Paradox.psp
anwser plz :P

Posted: Wed May 10, 2006 9:13 am
by dot_blank
HINTS:
it is not ascii
it is not 5 letters
it is not hexadecimal
it is not binary

;)
thats all i give