Re: Formatting query output

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Pedro Miguel Frazao Fernandes Ferreira <pfrazao(at)ualg(dot)pt>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Formatting query output
Date: 2002-10-29 00:50:14
Message-ID: 20021029005014.GE29873@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Oct 28, 2002 at 02:56:20PM +0000, Pedro Miguel Frazao Fernandes Ferreira wrote:
> Hi All,
>
> I am using libpq to interface PostgreSQL with Matlab.
> My question is about formatting query results:
>
> If I have a table field which is of type float8 and I insert, for
> example, a value of 4503599627370496, when I do a select on this table
> field I get 4.5035996273705e+15.

I think the reason for that is that float8s can only store about 16
significant digits anyway so you're cutting pretty close to the line.
Remember, floating point numbers are accurate but not precise. Do you really
need that extra digit of precision?

Maybe you should be using numeric() type for this. Actually, it looks like a
credit card number, perhaps you should use a string if you're not actually
doing calculations on it.

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lee Harr 2002-10-29 00:52:19 Re: newbie question for return date
Previous Message Bruce Momjian 2002-10-29 00:45:10 Re: VACUUM FULL not working with persistent connections in