I've just begun class on IT .
And i'm not very familiar with Computer Representation and the 2's complement.
e.g. find the 16-bit comp repn of -5131
1st step is to convert to binary , but how?
I'm not very sure , anyone familiar with this please help me .
ah digital electronics :D
will post up a working later.
For Negative numbers you have to put a sign bit of 1
For positive numbers you ahve to put a sign bit of 0
so it will be 1.
5131 is in digits (Base 10)
you have to convert 5131 to binary /oct*/hex*
* if you do it in oct or hex, you have to convert them back to bin numbers.
After you get the bin number, do a ones complement (all ones to zero ), (all zeros to ones)
Then do a twos complement by adding 1.
There you will have your answer.
Update: Cleared out unnecessary steps
okay , the negative and positive sign bits i'm clear about that ,
um no it didnt say anything about which base was it .
the answer stated there is , 110101111110101 (15-bit)
but i got 0110101111110100 (16-bit)
So idk whether is it correct .
5131 to binary is 1010000001011 (13 bits)
so we add 0001010000001011 to make it 16 Bits
Now we 2s complement it.
It will be
1110101111110101 Bits
Sorry for handwriting, my pen is failing
-Double post-
let me add on. It's alright to add 0 in it. Cause adding 0 to the binary ( 1010000001011) still makes it the same value (000 1010000001011) 5311.
Any conversion method would do. Be it Dec to Bin or Dec to Oct or Dec to Hex.
Of course. If you realize repeated divisions by 16 is faster than repeated divisions by 2 or 8.
In exams it's advised to do repeated divisions of 16 to get your Hex number and convert it to binary. Saves the trees and saves precious time.
WOAH . COOL PILLOW .
and kenn3th too !
Funny drawing !
Messy but understandable . THANKS
-edit-
work it out .
i divided it by 16.
got .. 1 4 0 1 .
convert to bin . 001001000000001 .
right?
You got Careless mistake, not 1401, but 140B
Does the course you are studying now do a lot of maths?
If yes you can buy one of these casio calculator(Make sure it is certified for use in exam beforebuying), if not then you might not want to waste the money
I bought this calculator because im doing electronics engineering so i need to convert many binary to hex, octal decimal, and calculate a lot of electrical stuff using differentiation/integration .
It can also do matrix, vectors, add/subtract/convert rectangular form to polar form, statistics, quadratic equations, and many other things i have not seen before
I know one thing this calculator cannot do, which is calculate the subnet ip address, and those sort of things
If you are using the sharp one from secondary school, they can convert too!
Cost around 30-40 plus
Originally posted by 93'guy:WOAH . COOL PILLOW .
and kenn3th too !
Funny drawing !
Messy but understandable . THANKS
-edit-
work it out .
i divided it by 16.
got .. 1 4 0 1 .
convert to bin . 001001000000001 .
right?
Well, I think you are abit confused through the conversion to Bin from Hex.
Just note that 1 Hex number is a 4 Bit binary Number.That's why Hex is preferred as it simplifies the whole binary equation. It's easier to read too.
Thus it's the same
Though the actual answer is 140B
---------------------------------
I will use 1401 (Hex) as an example of conversion to (Bin)
Since taking into account 1 Hex number is equals to 4 Binary Numbers
1 Hex will be 0001
4 Hex will be 0100
0 Hex will be 0000
Thus. Conversion of 1401 Hex to Bin is
0001 0100 0000 0001