| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера