Re: BUG #14138: Inconsistent rounding behavior in float4 coercion

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: BUG #14138: Inconsistent rounding behavior in float4 coercion
Дата
Msg-id CA+bJJbzKreSiNd7tKUXRMHGNBYb380qPNAvYRaGtya0wUQHDBg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #14138: Inconsistent rounding behavior in float4 coercion  (Charles <cooper.charles.m@gmail.com>)
Список pgsql-bugs
Charles..

On Sun, May 22, 2016 at 9:18 PM, Charles <cooper.charles.m@gmail.com> wrote:
> As a follow-up question, I am a bit confused as to the following behavior:
>
> elsendb=> set extra_float_digits = 3;
...
> elsendb=> select 11143.15 :: float4 :: text :: float4;
...
>  11143.1504
> elsendb=> select 11143.15 :: float4 :: numeric :: float4;
...
>  11143.2002

> How come 11143.1504 is not printed in all of these cases?

Probably because extra_f_d only plays when converting to/from text,
and not to numeric. It really is a mechanism to insure that text dumps
+ restores do not modify data. The other way is to use hex or binary
floating ( %a in printf  ) in dumps, which,  IIRC, postgres did
understand on input but had no way to generate on output.

If you insist on mixing finite precisison binary fractions ( float )
with decimal fractions ( numeric and/or text ) you should be prepared
for this. Do not do it or use a text intermediate step always so you
can control it.


Francico Olarte.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #14154: In pgpool while using delete query inside postgresql function , it is not deletingdata from all serve
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #14138: Inconsistent rounding behavior in float4 coercion