Thread: How many digits are printed with double precision?

How many digits are printed with double precision?

From
Mathieu Dubois
Date:
Hello,

I'm using postgreSQL and python (PyGreSQL) and face a strange problem.

I have a double precision column in my DB (it's the time at which an image was taken expressed in second from UNIX epoch). When I query the value (SELECT time...) I get only 5 digits after the dot (while I suppose there are 6 digits). I have the same result when using pgadmin. The results looks like the rounding of the desired time (which I know by the filename).

Is it because postgreSQL only returns a fixed amount of digits or is the mistake is coming from my INSERTion (something like a semiconscious rounding).

Thanks in advance,
Mathieu

Re: How many digits are printed with double precision?

From
Tom Lane
Date:
Mathieu Dubois <mathieu.dubois@limsi.fr> writes:
> I have a double precision column in my DB (it's the time at which an
> image was taken expressed in second from UNIX epoch). When I query the
> value (SELECT time...) I get only 5 digits after the dot (while I
> /suppose/ there are 6 digits). I have the same result when using
> pgadmin. The results looks like the rounding of the desired time (which
> I know by the filename).

See extra_float_digits.  Be aware that cranking that up produces digits
that are not 100% trustworthy.  If you are expecting exact results of
more than 15 places, you likely shouldn't be using float arithmetic.

            regards, tom lane

Re: How many digits are printed with double precision?

From
Mathieu Dubois
Date:
Hi Tom,

Thanks for the very fast answer but what do you mean exactly by :

"See extra_float_digits."

I have found messages on the mailing list but it doesn't help (I don't
want to recompile everything). Is there an option in some configuration
file to set?

Mathieu
On 03/23/2011 10:02 PM, Tom Lane wrote:
> Mathieu Dubois<mathieu.dubois@limsi.fr>  writes:
>> I have a double precision column in my DB (it's the time at which an
>> image was taken expressed in second from UNIX epoch). When I query the
>> value (SELECT time...) I get only 5 digits after the dot (while I
>> /suppose/ there are 6 digits). I have the same result when using
>> pgadmin. The results looks like the rounding of the desired time (which
>> I know by the filename).
> See extra_float_digits.  Be aware that cranking that up produces digits
> that are not 100% trustworthy.  If you are expecting exact results of
> more than 15 places, you likely shouldn't be using float arithmetic.
>
>             regards, tom lane
>


Re: How many digits are printed with double precision?

From
Frank Bax
Date:
http://lmgtfy.com/?q=postgresql+documentation+extra_float_digits


On 03/23/11 17:24, Mathieu Dubois wrote:
> Hi Tom,
>
> Thanks for the very fast answer but what do you mean exactly by :
>
> "See extra_float_digits."
>
> I have found messages on the mailing list but it doesn't help (I don't
> want to recompile everything). Is there an option in some configuration
> file to set?
>
> Mathieu
> On 03/23/2011 10:02 PM, Tom Lane wrote:
>> Mathieu Dubois<mathieu.dubois@limsi.fr> writes:
>>> I have a double precision column in my DB (it's the time at which an
>>> image was taken expressed in second from UNIX epoch). When I query the
>>> value (SELECT time...) I get only 5 digits after the dot (while I
>>> /suppose/ there are 6 digits). I have the same result when using
>>> pgadmin. The results looks like the rounding of the desired time (which
>>> I know by the filename).
>> See extra_float_digits. Be aware that cranking that up produces digits
>> that are not 100% trustworthy. If you are expecting exact results of
>> more than 15 places, you likely shouldn't be using float arithmetic.
>>
>> regards, tom lane

Re: How many digits are printed with double precision?

From
Mathieu Dubois
Date:
OK, I finally found it. Thanks I will try to set the value to 1 or 2 for
the moment.

On 03/23/2011 10:35 PM, Frank Bax wrote:
>
> http://lmgtfy.com/?q=postgresql+documentation+extra_float_digits
>
>
> On 03/23/11 17:24, Mathieu Dubois wrote:
>> Hi Tom,
>>
>> Thanks for the very fast answer but what do you mean exactly by :
>>
>> "See extra_float_digits."
>>
>> I have found messages on the mailing list but it doesn't help (I don't
>> want to recompile everything). Is there an option in some configuration
>> file to set?
>>
>> Mathieu
>> On 03/23/2011 10:02 PM, Tom Lane wrote:
>>> Mathieu Dubois<mathieu.dubois@limsi.fr> writes:
>>>> I have a double precision column in my DB (it's the time at which an
>>>> image was taken expressed in second from UNIX epoch). When I query the
>>>> value (SELECT time...) I get only 5 digits after the dot (while I
>>>> /suppose/ there are 6 digits). I have the same result when using
>>>> pgadmin. The results looks like the rounding of the desired time
>>>> (which
>>>> I know by the filename).
>>> See extra_float_digits. Be aware that cranking that up produces digits
>>> that are not 100% trustworthy. If you are expecting exact results of
>>> more than 15 places, you likely shouldn't be using float arithmetic.
>>>
>>> regards, tom lane
>