English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In C programming on Dos operating system an intiger number will take two bytes. The lefter most bit is using for storing a sign. For negative numbers it will be 1 and for positive nubers it will be zero. Is it symbly changing the value in that field or will there be any difference in other bits.

2006-07-26 04:07:24 · 3 answers · asked by kunjan 1 in Computers & Internet Programming & Design

3 answers

You must invert all bits and then add 1.
4-bit example:

1111 -1
invert
0000
add 1
0001
and back..
invert 0001
1110
add 1
1111

2006-07-26 04:16:01 · answer #1 · answered by sheeple_rancher 5 · 0 0

Most systems use 2s complement to represent signed integers

http://en.wikipedia.org/wiki/2%27s_complement_notation

Read any of the 100s of explanations on the web. Simply flipping the MSB will not give you the correct answer.

2006-07-26 04:27:35 · answer #2 · answered by Anonymous · 0 0

nope, all you should need to do is modify that bit.

2006-07-26 04:10:41 · answer #3 · answered by John J 6 · 0 0

fedest.com, questions and answers