Re: [PATCH] expand the units that pg_size_pretty supports on output

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: [PATCH] expand the units that pg_size_pretty supports on output
Дата
Msg-id CAApHDvrXt8OgEBHX3FZrbmxLb=sxWFNe65g+4i3wYBxkLT6YvQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] expand the units that pg_size_pretty supports on output  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Список pgsql-hackers
On Wed, 7 Jul 2021 at 00:51, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> 10. half_round(21) == 11 :: 20 >> 1 = 10
>
> The correct result should be 10 (it would be very odd to claim that
> 10241 bytes should be displayed as 11kb), but the half-rounding keeps
> rounding up at each stage.
>
> That's a general property of rounding -- you need to be very careful
> when rounding more than once, since otherwise errors will propagate.
> C.f. 4083f445c0, which removed a double-round in numeric sqrt().

Thanks. I've adjusted the patch to re-add the round bool flag and get
rid of the rightShift field.  I'm now calculating how many bits to
shift right by based on the difference between the unitbits of the
current and next unit then taking 1 bit less if the next unit does
half rounding and the current one does not, or adding an extra bit on
in the opposite case.

I'll post another patch shortly.

David



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

Предыдущее
От: Bharath Rupireddy
Дата:
Сообщение: Re: Refactor "mutually exclusive options" error reporting code in parse_subscription_options
Следующее
От: David Rowley
Дата:
Сообщение: Re: [PATCH] expand the units that pg_size_pretty supports on output