Solved

Converting from hexadecimal using two's compliment

Posted on 2014-04-19
2
268 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 26

Expert Comment

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Hello to users to the new age of computers. There are so many products to choose from nowadays that you maybe confused to understand which product is the correct product for you. Let me explain briefly what should be the idea product for your best n…
Does your iMac really need a hardware upgrade? Will upgrading RAM speed-up your computer? If yes, then how can you proceed? Upgrading RAM in your iMac is not as simple as it may seem. This article will help you in getting and installing right RA…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now