Google Answers Logo
View Question
 
Q: Floating-Point Respresentations ( Answered,   4 Comments )
Question  
Subject: Floating-Point Respresentations
Category: Computers > Programming
Asked by: infogamer-ga
List Price: $2.00
Posted: 21 Mar 2005 18:26 PST
Expires: 20 Apr 2005 19:26 PDT
Question ID: 498336
Because of the limitations of floating-point representations, which
kind of numbers do computers fail to perfectly represent-negative
numbers or extremely small numbers? Why? Where could I find more
information on the web on this topic?
Answer  
Subject: Re: Floating-Point Respresentations
Answered By: maniac-ga on 21 Mar 2005 20:01 PST
 
Hello Infogamer,

The set of numbers that cannot be represented exactly in floating
point is is basically equivalent to the set of numbers that do not
have an exact value as a floating point fraction. Something as simple
as 0.1 CANNOT be represented exactly as a floating point number. But a
negative number like -0.5 can be represented exactly. The latter has
an exact representation because 1/2 can be represented exactly as a
binary fraction.

  http://www.nuvisionmiami.com/books/asm/workbook/floating_tut.htm
is a pretty good tutorial on floating point numbers. It uses IEEE
format floating point (the most common) as the data representation.

Note that the mantissa (the binary fraction) has a limited precision.
This basically limits the number of significant digits (roughly 5 for
a single precision floating point).

Note also that the exponent (the binary exponent) has a limited range
as well. This limits how large / small the value will be.

For more good references, try a search like:
  floating point binary representation
  floating point binary tutorial
or similar phrases.

  --Maniac

Request for Answer Clarification by infogamer-ga on 22 Mar 2005 14:46 PST
Floating point representations aren't able to perfectly represent
extremely small numbers is what I understand the answer to be, such as
imaginary numbers and numbers to the left of the decimal point. Is
this correct? Thank-you so much for the link to the Floating Point
Tutorial.

Clarification of Answer by maniac-ga on 22 Mar 2005 20:21 PST
Hello Infogamer,

I do not understand what you mean by "extremely small numbers". There
are a number of small values that floating point can perfectly
represent and other values that it cannot perfectly represent.

For example:
  3/1048576  (basically 3/(2^20))
is a value that can be represented exactly yet
  3/1000000
cannot be represented exactly. Note the smaller value can be
represented exactly while the larger cannot. This gets back to the
statement I made previously about binary fractions.

In a similar manner, a value like
  3145728  (basically 3*(2^20)
can be represented exactly but
  3000000
cannot because there are not enough significant digits in the mantissa
in a single precision (32 bit) floating point value.

Imaginary numbers require a pair of values. For example, the square
root of -1 can be represented as:
  0.0, 1.0
which has a real value of zero and imaginary value of one.

I suggest you work through several examples using the floating point
tutorial to more clearly understand the values that can and cannot be
represented in floating point.

  --Maniac

Request for Answer Clarification by infogamer-ga on 22 Mar 2005 21:07 PST
Computers don't represent certain types of numbers, due to
floating-point representations, which may be either A.)extremely large
numbers, B.)extremely small numbers,  C.)numbers with values with
repeating fractional digits or D.) negative numbers. Which of these
choices might be the answer?

Clarification of Answer by maniac-ga on 23 Mar 2005 11:25 PST
Hello Infogamer,

To summarize the classes you refer to. Do not means the floating point
value does not represent the value exactly. Do means the floating
point value can represent the value exactly. Maybe depends on the
situation as described.

A - Do not, if extremely large is greater than the range of the exponent.
B - Do not, if extremely small is less than the range of the exponent.
C - Maybe, it depends on the value. Some values can repeat in decimal
and not in binary (and vice versa).
D - Do, if the positive value would otherwise be represented exactly.

Again, I suggest you review the tutorial (and other references from
the search phrases) more carefully so you understand the concept
behind the values represented in floating point on the computer.

  --Maniac
Comments  
Subject: Re: Floating-Point Respresentations
From: frde-ga on 23 Mar 2005 01:07 PST
 
<quote>
Computers don't represent certain types of numbers, due to
floating-point representations, which may be either A.)extremely large
numbers, B.)extremely small numbers,  C.)numbers with values with
repeating fractional digits or D.) negative numbers. Which of these
choices might be the answer?
</quote>

None of the above is the real problem.

It is down to the IEEE format, which is the general standard for floats

Simplistically, the decimal number is converted to 2^n
- and n is what is stored

As maniac-ga pointed out, some numbers /cannot/ be represented as 2^n
- so a little inaccuracy creeps in.

IEEE is not the only format for storing numbers
- two others are 
  Currency - 64bit Integer with an implied 4 decimal places
  BCD      - Binary Coded Decimal
Subject: Re: Floating-Point Respresentations
From: infogamer-ga on 28 Mar 2005 14:44 PST
 
Without gettig too involved, the answer to this question seems to me
to be that values with repeating fractional digits are the numbers
computers don't represent perfectly due to the limitions of
floating-point represetations, because of the fact that they are
irrational numbers.
Subject: Re: Floating-Point Respresentations
From: frde-ga on 29 Mar 2005 22:21 PST
 
@infogamer-ga 

No, it is not that simple

I vaguely remember that 82.24 is another 'problem' number

The problem is that some time in the early 1980's people decided that
it was better to optimize computers for floating point numbers
- for multiplication rather than addition.
Subject: Re: Floating-Point Respresentations
From: infogamer-ga on 30 Mar 2005 12:38 PST
 
I read over the tutorial and I have decided that negative numbers
might be the numbers that computers can't represent perfectly with
floating-point representaitons because they require a 1 to be the sign
bit, and that might take alot of 1s in a binary number for the MSB.
Logically, this makes the most sense because I can't possibly think of
anything else.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy