Re: Re: [GENERAL] Trouble with float4 afterupgrading from 6.5.3 to 7.0.2

From: Don Baccus <dhogaza(at)pacifier(dot)com>
To: Philip Warner <pjw(at)rhyme(dot)com(dot)au>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, Romanenko Mikhail <mikhail(at)angg(dot)ru>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [GENERAL] Trouble with float4 afterupgrading from 6.5.3 to 7.0.2
Date: 2000-08-08 12:50:00
Message-ID: 3.0.1.32.20000808055000.014353d0@mail.pacifier.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

At 01:37 PM 8/8/00 +1000, Philip Warner wrote:

>- do an intermediate text or numeric conversion. This will produce more
>expected results

By who? I'm serious. I sure wouldn't. I can't think of any language
implementation that does this. The standard approach has the advantage
of maintaining a defined significance. The approach you suggest doesn't,
you're actually losing significance. It gives the illusion of increasing
for the particular example you've chosen, but it is nothing but illusion.

>Would it be worth having some kind of DB setting for how it handles
>float4/8 conversion?

Use type numeric when you need precise decimal results. Your suggested
kludge won't give you what you want.

>Do you know how fast 'numeric' is?

Not as fast as float by any means, but there's a reason why they exist
in all languages which include the financial sphere in their presumed
application space.

The simplest thing is to realize that using float4 leaves you with
just over 7 significant digits, and to only print out 7 digits.
Then you'll get the answer you expect (10.100000).

- Don Baccus, Portland OR <dhogaza(at)pacifier(dot)com>
Nature photos, on-line guides, Pacific Northwest
Rare Bird Alert Service and other goodies at
http://donb.photo.net.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert D. Nelson 2000-08-08 13:17:00 RE: pg_dump help
Previous Message Steve Heaven 2000-08-08 12:47:34 Re: Query plan and sub-queries

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-08-08 13:21:02 Re: AW: UNIONS
Previous Message Steve Heaven 2000-08-08 12:47:34 Re: Query plan and sub-queries