Register to reply 
Negative Number into Hexadecimal 
Share this thread: 
#1
Feb2207, 12:36 PM

P: 14

how would you convert a negative number into a hexadecimal format?



#2
Feb2207, 01:34 PM

Emeritus
Sci Advisor
PF Gold
P: 2,361

One is to use a sign bit, where the MSB represents the sign (1 meaning negative. Thus 01 would represent +1 and 81 would represent 1 for two digit Hex numbers Another is two's complement. Here you invert all the bits and then add 1 to the result. thus 01 still represents +1 and FF represents 1. The advantage of two's complement is that it is easy to do with logic gates, and gives a result that you can add directly. For example, FF + 01 =00 (ignoring the carry) other examples: 0C + FA = 07 (12 + (5) = +7) 05 + F3 = F9 (5+(12) =7) 


#3
Feb2207, 02:00 PM

Mentor
P: 15,157

There are a couple of other methods in use: one's complement and excessn notation. Ones complement is even easier to implement than two's complement: simply flip each bit. In excessn notation, 0 represents n, 1 represents n+1, and so on.
One problem with signed magnitude and ones complement notation is that both have positive and negative zero as different numbers. This is one of the reasons these two techniques have largely been abandoned. Two's complement is the dominant mechanism by which negative numbers are represented in binary. There is one important exception: Excessn notation is used to represent the exponent in the IEEE floating point representation. 


Register to reply 
Related Discussions  
Sets with negative number of elements?  Set Theory, Logic, Probability, Statistics  6  
Can you take an even root of a negative number?  General Math  14  
Square Root of a Negative Number?  General Math  20  
Natural Log of negative number  Calculus  3  
Log of a negative number  Introductory Physics Homework  5 