Re: avg() with floating-point types

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: avg() with floating-point types
Дата
Msg-id 26697.1136165150@sss.pgh.pa.us
обсуждение исходный текст
Ответ на avg() with floating-point types  ("George Pavlov" <gpavlov@mynewplace.com>)
Список pgsql-sql
"George Pavlov" <gpavlov@mynewplace.com> writes:
> The datatype of both city.latitude and postal_code.latitude is
> number(16,12).
> This works, but I would like to understand why there is sometimes a
> discrepancy between avg(pc.latitude) and what actually gets inserted
> into the city table -- is it the usual floating-point discrepancy or is
> there something I can do about it? E.g. after the above update:

You're forcing the result of the avg() calculation to be rounded to 12
digits when you store it into city.latitude.  Your example simply shows
that the avg() calculation is being done to more precision than that.
        regards, tom lane


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

Предыдущее
От: "George Pavlov"
Дата:
Сообщение: avg() with floating-point types
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: avg() with floating-point types