Re: Formatting query output - Mailing list pgsql-general

From Tom Lane
Subject Re: Formatting query output
Date
Msg-id 24314.1035931296@sss.pgh.pa.us
Whole thread Raw
In response to Re: Formatting query output  (Pedro Miguel Frazao Fernandes Ferreira <pfrazao@ualg.pt>)
List pgsql-general
Pedro Miguel Frazao Fernandes Ferreira <pfrazao@ualg.pt> writes:
> When I store a float8
> number in a database, I am supposed to fetch the number as inserted.

I fear you have a fundamental misconception about the nature of
floating-point representation.  There is no such thing as "fetching the
number as inserted".  You get only as much accuracy as float8 format
will store, which is about half a digit less than you are asking for in
this case.

The fact that you might be able to store this particular 16-digit value
exactly is no guarantee that you'll be able to store other 16-digit
values exactly, so I recommend choosing another representation if
that's your requirement.  Blaming the output formatting is the wrong
way to look at it.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: User functions not displayed by \df
Next
From: Robert Treat
Date:
Subject: Re: PHP and PostgreSQL