Microsoft KB Archive/38027

= INFO: Negative Values Use Two's Complement =

Article ID: 38027

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Standard Edition
 * Microsoft Visual C++ 6.0 Service Pack 5

-



This article was previously published under Q38027





SUMMARY
In most C compilers, including the Microsoft C Compiler, negative values are represented internally in two's complement format. Two's complement can be obtained by negating each bit of the value, then adding 1. Performing two's complement twice generates the original value.

The following is an example:   Original Value               Two's Complement --

(dec)  (hex)  (binary)      (dec)   (hex)   (binary) 127    0x7f   01111111      -127    0x81    10000001 111    0x6f   01101111      -111    0x91    10010001 -111    0x91   10010001       111    0x6f    01101111

Additional query words: 8.00 8.00c 9.00

Keywords: kbinfo kbcompiler KB38027

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.