Re: Formatting query output - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Formatting query output
Date
Msg-id 20021029005014.GE29873@svana.org
Whole thread Raw
In response to Formatting query output  (Pedro Miguel Frazao Fernandes Ferreira <pfrazao@ualg.pt>)
List 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@svana.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.

Attachment

pgsql-general by date:

Previous
From: Lee Harr
Date:
Subject: Re: newbie question for return date
Next
From: Medi Montaseri
Date:
Subject: Re: newbie question for return date