Thread: Re: [OT] somebody could explain this?

Re: [OT] somebody could explain this?

From
"Kevin Grittner"
Date:
I think the crucial point is that the common IEEE floating point
formats are unable to store an EXACT representation of common
decimal fractions (such as .1) -- they can only store an
APPROXIMATION.

>>> Peter Eisentraut <peter_e@gmx.net>  >>>
Csaba Nagy wrote:
> [snip]
>
> > Floating points numbers are accurate but not precise.
>
> OK, now this one beats me... what's the difference between "accurate"
> and "exact" ? I thought both mean something like "correct", but
> precise refers to some action and accurate applies to a situation or
> description...

Accurate means close to the real value, precise means having a lot of 
detail.

So 3 is more accurate than 4 as a representation of "Pi", but both are 
not very precise.

5.32290753057207250735 is a very precise representation of "Pi" but 
totally inaccurate.

This also means that the statement at the top is wrong.  It should be 
the other way around.

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster



Re: [OT] somebody could explain this?

From
"Otto Hirr"
Date:
Lets start with an agreed upon expert, Knuth.
The art of computer programming. Vol2,Seminumerical Algorithms.Ed2.
pg682: Precision: The number of digits in a representation.
pg212: Section: Accuracy of floating point numbers.
"A rough (but reasonably useful) way to express the behavior of
floating point arithmetic can be based upon the concept of
"significant figures" or relative error."

The float point rep is built of a exponent and fractional part.
(Note mantissa means "a worthless addition"(pg199)

Most notably, the IEEE rep, either single or double, most certainly
has the ability to store the EXACT value for 0.1.

The issue is how to REPRESENT an exact value in the computer.
Some values may be represented exactly. Some values may not.
The tricky part is then operations on these values. We may have
exact representation of two values, then applying an operation
that results in a theoretical value that can only have an
approximate representation. Accuracy deals with the difference
between the theoretical exact value and our ability to
represent it.

Note that Knuth's observation about add/sub v. mul/div:

"Roughly speaking, the operations of floating point multiplication
and division do not magnify the relative error by very much; but
floating point subtraction of nearly equal quantities (and floating
point addition, u+v, where u is nearly equal to -v) can very greatly
increase the relative error."

Surprised?

Things to consider:
Is the value I want to represent have, shall we say, a limit to
the number of digits required to fully define its value,
eg 0.5, 0.9987

Is the value I want to represent have no limit to the number of
digits, eg pi, etc.

Does my representation provide a value that is within acceptable
limits of error, between the rep and actual value.

!Are the operations that I am performing introducing greater
amounts of relative error!

Break out the old computer book/math book and review...
Lets not assume or re-invent the wheel.

..Otto

> I think the crucial point is that the common IEEE floating point
> formats are unable to store an EXACT representation of common
> decimal fractions (such as .1) -- they can only store an
> APPROXIMATION.
> 
> >>> Peter Eisentraut <peter_e@gmx.net>  >>>
> Csaba Nagy wrote:
> > [snip]
> >
> > > Floating points numbers are accurate but not precise.
> >
> > OK, now this one beats me... what's the difference between 
> "accurate"
> > and "exact" ? I thought both mean something like "correct", but
> > precise refers to some action and accurate applies to a situation or
> > description...
> 
> Accurate means close to the real value, precise means having a lot of 
> detail.
> 
> So 3 is more accurate than 4 as a representation of "Pi", but 
> both are 
> not very precise.
> 
> 5.32290753057207250735 is a very precise representation of "Pi" but 
> totally inaccurate.
> 
> This also means that the statement at the top is wrong.  It should be 
> the other way around.
> 
> -- 
> Peter Eisentraut
> http://developer.postgresql.org/~petere/
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
> 
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
> 



Re: [OT] somebody could explain this?

From
Tom Lane
Date:
"Otto Hirr" <otto.hirr@olabinc.com> writes:
> Most notably, the IEEE rep, either single or double, most certainly
> has the ability to store the EXACT value for 0.1.

Oh really?
        regards, tom lane


Re: [OT] somebody could explain this?

From
"Otto Hirr"
Date:
yes, MAJOR goof on my part. My brain cells were not firing quite right :(
For those really interested, here are some resources:
http://www.cs.wisc.edu/~cs354-1/cs354/karen.notes/reps.flpt.html
http://cch.loria.fr/documentation/IEEE754/ACM/goldberg.pdf
http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html


> -----Original Message-----
> From: pgsql-hackers-owner@postgresql.org
> [mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Tom Lane
> Sent: Friday, November 04, 2005 11:52 AM
> To: otto.hirr@olabinc.com
> Cc: pgsql-hackers@postgresql.org
> Subject: Re: [OT] somebody could explain this? 
> 
> 
> "Otto Hirr" <otto.hirr@olabinc.com> writes:
> > Most notably, the IEEE rep, either single or double, most certainly
> > has the ability to store the EXACT value for 0.1.
> 
> Oh really?
> 
>             regards, tom lane
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>