bitwise and hexadecimal :S

General, off-topic discussion about things of interest to the members of these forums.

Moderator: cheriff

Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

bitwise and hexadecimal :S

Post 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
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post 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
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post 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?
johnsto
Posts: 30
Joined: Wed Jan 18, 2006 8:52 am

Post 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
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post 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 ;)
10011011 00101010 11010111 10001001 10111010
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

Moved to offtopic, since this has nothing to do with PSP...
Shoot Pixels Not People!
Makeshift Development
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

all i get is

10011011
00101010
11010111
10001001
10111010

00010001
JorDy
Posts: 121
Joined: Sun Dec 11, 2005 8:45 am

Post 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
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

its hard to understand when ur only 13 ^_^

ok so what is 7b16 in just decimal?
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post 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
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post 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.
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post 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
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

Paradox.psp wrote:all i get is

10011011
00101010
11010111
10001001
10111010

00010001
incorrect
10011011 00101010 11010111 10001001 10111010
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

how about 00000000
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

Paradox.psp wrote:how about 00000000
incorrect
hint: try binary ;)
10011011 00101010 11010111 10001001 10111010
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

binary? lol
User avatar
Orfax
Posts: 21
Joined: Thu Apr 08, 2004 3:41 pm
Location: Adelaide, Australia
Contact:

Post by Orfax »

As they say, there are only 10 types of people in this world. Those that understand binary and those that don't. :)
Look deep into their eyes for what they have to say, Emotions take control of life everyday
Death (Nothing Is Everything)
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post 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 :)
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

what is it?
Viper8896
Posts: 110
Joined: Thu Jan 26, 2006 6:20 pm

Post by Viper8896 »

Paradox.psp wrote:what is it?
10 binary not ten decimal

10 binary = 2 decimal
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

the answer! :D
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

Paradox.psp wrote:the answer! :D
incorrect
10011011 00101010 11010111 10001001 10111010
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

telll me it!! ... how can u use binary? i need answer!
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post 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)
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post 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?
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post 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....
User avatar
Orfax
Posts: 21
Joined: Thu Apr 08, 2004 3:41 pm
Location: Adelaide, Australia
Contact:

Post 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).
Look deep into their eyes for what they have to say, Emotions take control of life everyday
Death (Nothing Is Everything)
cory1492
Posts: 216
Joined: Fri Dec 10, 2004 1:49 pm

Post 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.
Paradox.psp
Posts: 27
Joined: Mon Feb 06, 2006 6:06 am
Location: N.ireland LISBURN

Post by Paradox.psp »

anwser plz :P
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post 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
10011011 00101010 11010111 10001001 10111010
Post Reply