Solved

Converting from hexadecimal using two's compliment

Posted on 2014-04-19
2
274 Views
Last Modified: 2014-04-20
What are the steps you would take to convert a hexadecimal number such as 0x0AB00000 to a decimal number, knowing that it is an unsigned integer. Are there different steps to convert this number if you knew that it was two's compliment instead of an unsigned integer?
0
Comment
Question by:pcomb
2 Comments
 
LVL 15

Accepted Solution

by:
ChloesDad earned 500 total points
ID: 40010525
Yes,

The first step is the same either way as you need to convert the hex number to binary

In your example it is

00001010 10110000 00000000 00000000

This converts to a positive decimal value of 179306496

For a two's compliment, the most significant bit defines the sign, in this case, its 0 so its a positive number.

If we ignored your leading 0 in the hex string, and it was AB00000 then the first 4 0's are now not present and the most significant bit is now a 1 indicating a negative number.

The decimal value of the remaining bits is 45088768, and to get the negative value we subtract this value from 2^N where N is the number of bits in the original number (28)

2^28 = 268435456

so number = 268435456 - 45088768 = -223346688

Using a simpler example

10000000 = 2^8 - 0 = -128
11111111 = 2^8 - 127 = -1
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 40011081
$ echo 'ibase=16 ; ob=10 ; 0AB00000' | bc
179306496
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
A clone is a duplicate copy. Sheep have been cloned and maybe someday even people will be cloned, but disk cloning (performed by the hard drive cloning software) is a vital tool used to manage and protect data. Let’s look at what hard drive cloning …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question