473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sign magnitude, ones complement, two's complement

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?
Nov 13 '05 #1
8 14380
Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement What are the pitfalls of them?


I doubt if sign magnitude has ever been used in a popular US computer. The
disadvantage of ones complement is that there are two representations for 0,
"positive" zero and negative zero. OTOH subtraction is less onerous with a
ones complement hardware design.

Two's complement is certainly the dominant form in current computers.
Nov 13 '05 #2

"osmium" <r1********@com cast.net> wrote in message
news:bl******** ****@ID-179017.news.uni-berlin.de...
Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement
What are the pitfalls of them?


I doubt if sign magnitude has ever been used in a popular US computer.

The disadvantage of ones complement is that there are two representations for 0, "positive" zero and negative zero. OTOH subtraction is less onerous with a ones complement hardware design.
I believe the IBM 7090. But then they internally convert to ones complement
to do addition and subtraction.

Multiply and divide are easier in sign magnitude, and I believe divide is
done that way on most computers now.
Two's complement is certainly the dominant form in current computers.


Except for those made by Univac.

-- glen
Nov 13 '05 #3
Glen Herrmannsfeldt writes:
I doubt if sign magnitude has ever been used in a popular US computer.
I believe the IBM 7090. But then they internally convert to ones complement to do addition and subtraction.


I'll be damned! And also the 7094 according to this link. Just to cloud
the issue they use twos complement for some index fiddling if you look at
the instruction repertoire; which is also on this site.

http://www.frobenius.com/binary.htm
Nov 13 '05 #4
>From least to greatest is it

Least to greatest *WHAT*? Number of transistors in the CPU
to implement it? Tax rate? Weight of the documentation?
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?
Which is better, rat poison, a condom, or a Pepsi? It does rather
depend on what you want it for.
What are the pitfalls of them?


Unless you are designing a CPU or selecting one to buy, you don't
get to choose, and there are many MANY factors much more important
than this (like availability of a good compiler for it).

Gordon L. Burditt
Nov 13 '05 #5
osmium wrote:
Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement

What are the pitfalls of them?


I doubt if sign magnitude has ever been used in a popular US
computer. The disadvantage of ones complement is that there are
two representations for 0, "positive" zero and negative zero.
OTOH subtraction is less onerous with a ones complement hardware
design.

Two's complement is certainly the dominant form in current
computers.


Actually arithmetic is more convenient in 2's complement, because
there is no need for end-around-carries.

However negation of a value is simpler in 1's complement. By
making the basic arithmetic operation a subtractor (rather than an
adder) you can avoid negative zero ever appearing, thus allowing
use of that value as a trap (e.g. uninitialized).

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!

Nov 13 '05 #6
osmium wrote:

Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement

What are the pitfalls of them?


I doubt if sign magnitude has ever been used in a popular US computer.


The first computer I ever programmed used signed magnitude.
Was it "popular?" Hard to tell, but IBM thought enough of the
design to build the machines and offer them in a range of sizes
(twenty, forty, or sixty thousand decimal digits of memory).

--
Er*********@sun .com
Nov 13 '05 #7
Eric Sosman wrote:

osmium wrote:

Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement

What are the pitfalls of them?


I doubt if sign magnitude has ever been used in a popular US computer.


The first computer I ever programmed used signed magnitude.
Was it "popular?" Hard to tell, but IBM thought enough of the
design to build the machines and offer them in a range of sizes
(twenty, forty, or sixty thousand decimal digits of memory).

Upthread, someone mentioned the last might have been the IBM 7094 which
came out in Jan 1963 and was the last of the 'Old Iron' before the
'Modern' IBM 360 and later. How 'popular' could the 7094 have been? How
many of them were built? I don't know the number. 100? More?

My first computer was the Philco 2000/212 which came out the same month
as the 7094. In long suit we had 32K of 48-bit (8-character) words of
RAM in four 8K banks. Each bank had a cycle time of 1.1 microseconds.
Bank selection was done in the low order two bits of address so that we
could get four 48-bit words every 1.1 usecs. This was 'core' memory with
real magnetic cores.

We left the 7094 for dead.

Philco Computers, Willow Grove, PA, R.I.P.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #8

"CBFalconer " <cb********@yah oo.com> wrote in message
news:3F******** *******@yahoo.c om...
osmium wrote:
Mantorok Redgormor writes:
sign magnitude
ones complement
two's complement
What are the pitfalls of them?

(snip)
Two's complement is certainly the dominant form in current
computers.


Actually arithmetic is more convenient in 2's complement, because
there is no need for end-around-carries.


With popular adder designs end-around carry isn't hard to do, and shouldn't
be slower. It complicates serial adders, but since the PDP-8S I don't know
that there have been any machines with serial binary adders.
However negation of a value is simpler in 1's complement. By
making the basic arithmetic operation a subtractor (rather than an
adder) you can avoid negative zero ever appearing, thus allowing
use of that value as a trap (e.g. uninitialized).


Yes, negation can be complicated with two's complement, as it can overflow.
On some machines this means processing a trap or exception for that case.

-- glen
Nov 13 '05 #9

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

Similar topics

37
25360
by: Claude Gagnon | last post by:
Hi, How can we compare sign of numbers in C++ ? Bye, Claude
4
52549
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
10
17891
by: Sona | last post by:
Hi, Could someone please explain what sign-extension means? If I have a hex number 0x55, how does this get sign-extended? Can a sign-extended counterpart be equal to -91? In a program I'm expecting 0x55 in return from a function whereas I am getting -91 every time.. does this mean anything? Thanks Sona
5
1420
by: John Devereux | last post by:
I was wondering what is the "best" way to set a variable to "all ones". In particular where I do not know the precise type of the variable (or more accurately, when I don't want to worry about it!). E.g. assume "a" is unsigned, but could be char, short, int or long. a = -1; or
7
2129
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))?
6
52670
by: Jason Heyes | last post by:
Does a function exist in the standard library to compute the sign of an integer? Example: int sign(int v) { return v > 0 ? 1 : (v < 0 ? -1 : 0); } Thanks.
14
10521
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.
8
8388
by: scrier | last post by:
Hi, What i'm trying to accomplice is to change the sign of an integer value. Not do the 2 complement so I get the negative value, but to change sign of something that already has done the 2 complement but has wrong sign nonetheless. int temp = 123456; temp |= 0x80000000; The above gives an error that I try to convert from long to integer. // Andreas
7
2379
by: schaefer.mp | last post by:
To compute the absolute value of a negative base raised to a fractional exponent such as: z = (-3)^4.5 you can compute the real and imaginary parts and then convert to the polar form to get the correct value: real_part = ( 3^-4.5 ) * cos( -4.5 * pi ) imag_part = ( 3^-4.5 ) * sin( -4.5 * pi )
0
9522
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
10111
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...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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
8770
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
7327
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
6603
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();...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
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

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.