Re: CONCAT function adding extra characters

Поиск
Список
Период
Сортировка
От Ron
Тема Re: CONCAT function adding extra characters
Дата
Msg-id b12a2a19-4290-b27a-5ab3-25ab82e1b0e2@gmail.com
обсуждение исходный текст
Ответ на CONCAT function adding extra characters  (AI Rumman <rummandba@gmail.com>)
Список pgsql-general
On 6/15/21 1:55 PM, AI Rumman wrote:
I am using Postgresql 10 and seeing a strange behavior in CONCAT function when I am concatenating double precision and int with a separator.

select concat('41.1'::double precision,':', 20);
Result:
41.1000000000000014:20

Value 41.1 which double precision converts to 41.1000000014.


Is that expected?

Because of the well-known difficulty in precisely converting floating point to decimal, in cases like this, I always cast to NUMERIC of the desired precision.  It's the COBOL programmer in me...

--
Angular momentum makes the world go 'round.

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: CONCAT function adding extra characters
Следующее
От: Mateusz Henicz
Дата:
Сообщение: Re: some questions regarding replication issues and timeline/history files