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

2005-11-06 Thread Otto Hirr
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: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Tom Lane
 Sent: Friday, November 04, 2005 11:52 AM
 To: [EMAIL PROTECTED]
 Cc: pgsql-hackers@postgresql.org
 Subject: Re: [OT] somebody could explain this? 
 
 
 Otto Hirr [EMAIL PROTECTED] 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
 


---(end of broadcast)---
TIP 6: explain analyze is your friend


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

2005-11-04 Thread Csaba Nagy
[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...

I'm actually curios what it means. Merriam-Webster refers for both to
correct as a synonym.

Cheers,
Csaba.



---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


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

2005-11-04 Thread Peter Eisentraut
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: [HACKERS][OT] somebody could explain this?

2005-11-04 Thread Kevin Grittner
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 [EMAIL PROTECTED]  
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: [HACKERS] [OT] somebody could explain this?

2005-11-04 Thread Bruno Wolff III
On Fri, Nov 04, 2005 at 18:30:56 +0100,
  Csaba Nagy [EMAIL PROTECTED] 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...
 
 I'm actually curios what it means. Merriam-Webster refers for both to
 correct as a synonym.

My memory from science courses a long time ago, is that precision refers
to how much information you have (e.g. the number of digits in a number)
and accuracy refers to how close your information is to reality.
Using a precision that was much higher than justified by accuracy used to
get points deducted from lab report grades.

In mathematics precise has a somewhat different meaning, but isn't a synonym
for accurate in that context.

---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


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

2005-11-04 Thread Otto Hirr
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 [EMAIL PROTECTED]  
 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
 


---(end of broadcast)---
TIP 6: explain analyze is your friend


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

2005-11-04 Thread Tom Lane
Otto Hirr [EMAIL PROTECTED] 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


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

2005-11-04 Thread Kevin Grittner
No, the IEEE formats can not store .1 exactly.  How close it
comes depends on the rest of the number.  For single and
double precision, respectively, the IEEE representations fall
at about:

0.10001490116119384765625
0.155511151231257827021181583404541015625

Libraries must do some rounding of these approximations when
formatting for display, so the error is rarely seen, except when
conversions to other data types are done via truncation.  The
problem values from the previous example were actually stored
as something close to the following.

0.11999555910790149937383830547332763671875
0.1499944488848768742172978818416595458984375

Whole numbers, on the other hand, are always accurate unless
they exceed the number of significant digits for the format.

-Kevin


 Otto Hirr [EMAIL PROTECTED]  
Most notably, the IEEE rep, either single or double, most certainly
has the ability to store the EXACT value for 0.1.


---(end of broadcast)---
TIP 6: explain analyze is your friend