2's complement of floating point numbers

WBahn

Joined Mar 31, 2012
29,979
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?
 

t06afre

Joined May 11, 2009
5,934
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
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
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.
 

WBahn

Joined Mar 31, 2012
29,979
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.
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.
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
Thanks for your attention.

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.
Why?

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

Zulfi.
 

WBahn

Joined Mar 31, 2012
29,979
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.
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
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.
 

t06afre

Joined May 11, 2009
5,934
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.
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
 

WBahn

Joined Mar 31, 2012
29,979
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.
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.
 

WBahn

Joined Mar 31, 2012
29,979
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
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.
 

Thread Starter

zulfi100

Joined Jun 7, 2012
656
Hi,
Thanks. I found from http://en.wikipedia.org/wiki/Fixed-point_arithmetic
A value of a fixed-point data type is essentially an integer that is scaled by a specific factor determined by the type. For example, the value 1.23 can be represented as 1230 in a fixed-point data type with scaling factor of 1/1000, and the value 1230000 can be represented as 1230 with a scaling factor of 1000. Unlike floating-point data types, the scaling factor is the same for all values of the same type, and does not change during the entire computation.
I think its clear to me. Fixed point is for example related to the population example provided by WBahn. Thanks.

Zulfi.
 

WBahn

Joined Mar 31, 2012
29,979
Hi,
Thanks. I found from http://en.wikipedia.org/wiki/Fixed-point_arithmetic

A value of a fixed-point data type is essentially an integer that is scaled by a specific factor determined by the type. For example, the value 1.23 can be represented as 1230 in a fixed-point data type with scaling factor of 1/1000, and the value 1230000 can be represented as 1230 with a scaling factor of 1000. Unlike floating-point data types, the scaling factor is the same for all values of the same type, and does not change during the entire computation.
I think its clear to me. Fixed point is for example related to the population example provided by WBahn. Thanks.

Zulfi.
Hmmm. I seem to recall someone saying,

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.
and

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.
Sometimes I feel like I'm ******* in the wind.

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