# 2's complement of floating point numbers

Discussion in 'Homework Help' started by zulfi100, Apr 25, 2013.

Jun 7, 2012
457
1
2. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
For your first question, if you are talking about the IEEE 754 floating point representations, then it is correct that 2's complement is not used. The exponent is represented using excess-N and the significand is represented using signed binary, which allows the significand to be conveniently split into a sign bit and an unsigned magnitude that can be represented and processed indepedently.

For your second question, I am assuming that you are using a fixed-point representation?

If so, then you are correct.

Where's the confusion?

3. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,227
I shal teach you a trick, to create 2's complement. Take the number given by you
010111.1100. Start on the least signifricant bit and locate the first 1 marked red 010111.1100. Then flip every bit after that first one (1 change to zero and vice verse) 010111.1100-> 101000.0100

4. ### zulfi100 Thread Starter Active Member

Jun 7, 2012
457
1
Hi,
Confusion is that the question does not say whether we have to use ieee754 or fixed point representation.
Thanks for 2's complement technique.
Zulfi.

5. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
Unless otherwise stated, you can pretty safely assume that any floating point representation is refering to the IEEE 754 standard.

But you do realize that your second question had absolutely nothing to do with ANY floating point representation, correct? It was a question about a fixed-point representation which, at the end of the day, is an integer representation.

6. ### zulfi100 Thread Starter Active Member

Jun 7, 2012
457
1
Hi,

Why?

Its a floating poinmt number having a decimal point. So it should be dealt using ieee 754 standards. Kindly guide me.

Zulfi.

7. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
Integers have a decimal point, too. It is located to the right of the last digit. Since there are no digits to the right of it, we can leave it off without causing confusion.

Technically, "decimal point" only applies to base 10. For base 2 it is called a "binary point". The term that is generic for any base is "radix point".

In a number such as 5.43, the radix point is "fixed" in that the weight of a given digit is determined by how far it is to the left of the right. Normally, the weight of the digit immediately to the left of the radix point is 1. But that is not always the case. For instance, what if that number is the population of a particular state? Most likely (and it would be stated someplace), the figure is in millions and the weight of the digit immediately to the left of the radix point is one million. But, for that data, the weight of that digit is always one million.

But in exponential notation the weight of the digit to the left of the radix point is determined by the exponent. So when we say 5.43E9, we mean that the 5 has a weight of 10^9. Thus, the radix point "floats" and can be located at a different position for each number.

In a computer (and elsewhere) we can represent fixed point numbers using integers by simply scaling the values and keeping track of the effect of the scaling factors. Thus, the internal representation can be kept as an integer representation and, thus, we can use 2's complement to represent negative fixed point values.

One thing to keep in mind is that whenever you talk about "two's complement", you are talking about a particular way of representing integer values, some of which might happen to be negative.

8. ### zulfi100 Thread Starter Active Member

Jun 7, 2012
457
1
Hi,
Thanks for this detail. But i feel that i did not get answer to my question. Is the number 010111.1100 floating point or not? If yes then why are we finding its 2's complement. This is a violation of ieee754 standards.

Zulfi.

9. ### t06afre AAC Fanatic!

May 11, 2009
5,939
1,227
The number 010111.1100 is something constructed. In a binary system. No such number exist. It is not floating point. But an attempt to use the the decimal system. To construct a binary decimal numeral. It is just nonsense from a computing point of view

10. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
In my very first response I stated that it was corrent only if you were using a FIXED point representation. This is NOT a floating point representation.

11. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
There have been numerous machines that have used fixed point architectures, though probably few, if any, in the last three or four decades. It is no more nonsense than any other representation, be it straight binary, one's comp, excess-3, or whatever. You define a representation that maps bit patterns to values and then you construct hardware/software to manipulate those bit patterns in ways consistent with the corresponding manipulations of the values they map to.

And it's not using the decimal system at all, it is using the binary system which is simply one specific instance of a positional numbering representation. The decimal system is merely another such specific instance.

12. ### zulfi100 Thread Starter Active Member

Jun 7, 2012
457
1
Hi,
Thanks. I found from http://en.wikipedia.org/wiki/Fixed-point_arithmetic
I think its clear to me. Fixed point is for example related to the population example provided by WBahn. Thanks.

Zulfi.

13. ### WBahn Moderator

Mar 31, 2012
22,990
6,884
Hmmm. I seem to recall someone saying,

and

Sometimes I feel like I'm ******* in the wind.

But, I'm glad you've finally gotten a handle on it.