Re: How PostgreSQL's floating-point hurts everyone everywhere

From: JanWieck(at)t-online(dot)de (Jan Wieck)
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: How PostgreSQL's floating-point hurts everyone everywhere
Date: 2000-07-20 17:28:59
Message-ID: 200007201728.TAA05724@hot.jw.home
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
>
> peter=# select 1.0/0.0;
> ERROR: float8div: divide by zero error
>
> Division by zero is not an "error" in floating point arithmetic.

No?

Oh, then 7 = 5 because:

Assuming 2a = b | * 2
4a = 2b | + 10a
14a = 10a + 2b | - 7b
14a - 7b = 10a - 5b | ()
7 (2a - b) = 5 (2a - b) | / (2a - b)
7 = 5

In the given context, you should find the mistake pretty
easy. Maybe the message should be changed to

ERROR: floatdiv: divide by zero nonsense
^^^^^^^^

because a division by zero results in nonsense? Or should it
just return a random value? What is the result of a division
by zero? It's definitely not infinity, as the above
demonstrates!

You might be looking from a managers PoV. Managers usually
use this kind of arithmetic to choose salaries. Any engineer
knows that

work = power * time

We all know that time is money and that power is knowlede. So

work = knowledge * money

and thus

work
money = ---------
knowledge

Obviously, the lesser you know, the more money you get,
independant of the work to be done. As soon as you know
nothing (zero), any money you get for the work is nonsense!

This applies well to the real world, so it makes sense from
an OO PoV. But in science, I think it's still an error.

Since PostgreSQL is an ORDBMS (not an OODBMS), I think it's
correct to report an error instead of returning some random.

:-)

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Brook Milligan 2000-07-20 18:01:30 Re: Re: [HACKERS] 8Ko limitation
Previous Message Henry B. Hotz 2000-07-20 17:03:51 Re: How PostgreSQL's floating-point hurts everyone everywhere