473,889 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

1's complement and 2's complement

Hi all,
I have a few doubts in the 1's and 2's complement
representation. Generally negative numbers can be represented using
either 1's complement or 2's complement representation.

1's complement ---reverse all the bits
2's complement ---reverse all the bits + 1

i.e 1's complement of 2 ( 0000 0010 ) is -2 ( 1111 1101 )
But when a number and its complement are added the result must be a
zero right ??
But in this case 0000 0010 + 1111 1101 = 1111 1111 ==[ ?? ]
Should'nt we be getting a zero as result ???

2's complement of 2 ( 0000 0010 ) is -2 ( 1111 1110 )
Adding we get , 0000 0010 + 1111 1110 = 0000 0000 ==[ OK]

Does this complement representation have anything to do with the C's ~
[1's complement] operator ?
Is this representation architecture dependent or compiler dependent ?

Please clarify,

Regards,
Sarathy

Aug 1 '06
20 45563

Roy Smith wrote:
That being said, I haven't seen a 1's complement
machine in a couple of eons. It's pretty much an obsolete concept as far
as hardware design goes.
Except of course as part of the format for IEEE floating point numbers
(float, double etc.).

http://www.arl.wustl.edu/~lockwood/c...ml#HEADING1-52
K

Aug 1 '06 #11

Roy Smith wrote:
It's pretty much an obsolete concept as far as hardware design goes.

Not quite, many DSP-oriented CPU's use 1's complement arithmetic.

The advantage is, in a chain calculation, the negates and carries can
be computed separately and andded back at the end. With two's
complement the "add one" has to be done on each negate.

Aug 1 '06 #12
"Kirit Sælensminde" <ki************ ****@gmail.comw rites:
Roy Smith wrote:
>That being said, I haven't seen a 1's complement
machine in a couple of eons. It's pretty much an obsolete concept as far
as hardware design goes.

Except of course as part of the format for IEEE floating point numbers
(float, double etc.).

http://www.arl.wustl.edu/~lockwood/c...ml#HEADING1-52
Actually, I think it's sign-and-magnitude, not one's-complement.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 1 '06 #13
In article <11************ **********@m79g 2000cwm.googleg roups.com"=?iso-8859-1?q?Kirit_S=E6l ensminde?=" <ki************ ****@gmail.comw rites:
>
Roy Smith wrote:
That being said, I haven't seen a 1's complement
machine in a couple of eons. It's pretty much an obsolete concept as far
as hardware design goes.

Except of course as part of the format for IEEE floating point numbers
(float, double etc.).

http://www.arl.wustl.edu/~lockwood/c...ml#HEADING1-52
I would not trust a book by an author who does not know the difference
between 1-s complement and sign-magnitude. The last machine I had
access to that used 1-s complement was the CDC Cyber 750, and the
successor in 750 mode (both for int and for float).
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Aug 1 '06 #14

Frederick Gotham wrote:
sarathy posted:
Please verify and revert back in case.


*Cringe*

I'd love to bludgeon to death the next person I hear utter that phrase.
I've never come across it before; what does it mean? Am I allowed to
revert to any previous condition, or is a particular one implied?

Aug 1 '06 #15
Dik T. Winter wrote:
In article <11************ **********@m79g 2000cwm.googleg roups.com"=?iso-8859-1?q?Kirit_S=E6l ensminde?=" <ki************ ****@gmail.comw rites:
>
Roy Smith wrote:
That being said, I haven't seen a 1's complement
machine in a couple of eons. It's pretty much an obsolete concept as far
as hardware design goes.
>
Except of course as part of the format for IEEE floating point numbers
(float, double etc.).
>
http://www.arl.wustl.edu/~lockwood/c...ml#HEADING1-52

I would not trust a book by an author who does not know the difference
between 1-s complement and sign-magnitude. The last machine I had
access to that used 1-s complement was the CDC Cyber 750, and the
successor in 750 mode (both for int and for float).
Nobody doubts there were 1's complement iron, but when? The last CDC
machine I saw was the 160A in 1962 and I have no idea of its arithmetic
mode. In 1963 I learned the Philco 212/2000 system which was 2's
complement. Every machine I've seen since then is 2's complement for
integer arithmetic. That's 43 years. But I haven't seen them all.

What was the last 1's complement machine and when was it last produced?

I have never seen 'signed magnitude' integers on any machine.

Of course, IEEE floating point is signed magnitude. FP is not the issue.

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Aug 2 '06 #16

Keith Thompson wrote:
Actually, I think it's sign-and-magnitude, not one's-complement.
Whoops. Fair enough.
K

Aug 2 '06 #17
In article <x9************ *************** ***@comcast.com >,
Joe Wright <jo********@com cast.netwrote:
What was the last 1's complement machine and when was it last produced?
Wikipedia (http://en.wikipedia.org/wiki/One%27s_complement) claims "the
PDP-1 and UNIVAC 1100/2200 series, among many others, used one's-complement
arithmetic."
Aug 2 '06 #18
"J. J. Farrell" <jj*@bcs.org.uk wrote:
Frederick Gotham wrote:
sarathy posted:
Please verify and revert back in case.
*Cringe*

I'd love to bludgeon to death the next person I hear utter that phrase.

I've never come across it before; what does it mean?
It's managementspeak . The presence of any meaning is purely optional.

Richard
Aug 2 '06 #19
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
"J. J. Farrell" <jj*@bcs.org.uk wrote:
>Frederick Gotham wrote:
sarathy posted:
Please verify and revert back in case.

*Cringe*

I'd love to bludgeon to death the next person I hear utter that phrase.

I've never come across it before; what does it mean?

It's managementspeak . The presence of any meaning is purely optional.
Most managers would be smart enough to use the word "report" rather
than "revert".

Apart from that, sarathy did give the impression that he was ordering
us around. That probably wasn't his intent. The difference in
wording between a polite request and a politely-phrased order to an
underling can be subtle.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Aug 2 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
52633
by: Abby | last post by:
I have an array which contain Hex no. in each position. For examples, unsigned char data; data = 0x00; data = 0x01; data = 0x02; data = 0xE; data = 0xEF; --> This is the checksum value
8
14384
by: Mantorok Redgormor | last post by:
From least to greatest is it sign magnitude ones complement two's complement Where sign magnitude is the least way to represent integers and two's complement is the best way to represent integers? What are the pitfalls of them?
33
7729
by: Daniel Fadlun | last post by:
Is there a bigger, mathematical, data type in C than the double (64 bit) one or the old long double (80 bit)? I'd like to add precision to my mathematical application, but I can't figure out how. Thanks alot.
7
2133
by: Greenhorn | last post by:
Hi, Is two's complement always used as a storage method or is it computed while computing the expression involved. e.g., int a = -2, b = 3, c = 4, d; d = b - c; Here, is 'a' stored as two's complement of '2'? or is '-c' (two's complement of c) computed on the fly and the resulting value is added to b ( b + (-c))?
22
979
by: sarathy | last post by:
Hi all, I have a few doubts in the 1's and 2's complement representation. Generally negative numbers can be represented using either 1's complement or 2's complement representation. 1's complement ---reverse all the bits 2's complement ---reverse all the bits + 1 i.e 1's complement of 2 ( 0000 0010 ) is -2 ( 1111 1101 ) But when a number and its complement are added the result must be a
6
4698
by: subramanian | last post by:
Suppose I have the following statement: unsigned char x = 0; If I do, printf("%u\", ~x); it prints the value of UINT_MAX. I am using Intel machine. This same result is printed in both VC++ and gcc.
14
10532
by: darthghandi | last post by:
What would be the most efficient way to calculate the two's complement of a variable length byte array? Thanks for your time.
3
7572
by: vijaybaskar3108 | last post by:
hi, I just want to know how to find complements for a number. These are the following answers for complements 2's complement(10110)=01010 4's complement(1230)=2110 5's complement(4322)=0123 please tell me how to do it.how this answers comes.This is a global edge question. please also tell me how to find 8's complement(7436) please alos tell me how to find 3's,4's,5's,6's,7's,8's complements.
6
3405
by: Dan Henry | last post by:
I need a sanity check. The following is an exchange on comp.arch.embedded with CBFalconer in a rather long MISRA related thread. Since my little section of that thread and area of interest was never really about MISRA, but rather the one's complement representation of integer constant 0 and now how to zero memory portably, I am bringing the topic to this group. Try to ignore CBF's errors in the 1's complement -1 and sign magnitude -1...
0
9969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10443
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9612
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7999
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7151
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4650
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3257
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.