Re: Add numeric_trim(numeric)
От | Dean Rasheed |
---|---|
Тема | Re: Add numeric_trim(numeric) |
Дата | |
Msg-id | CAEZATCWE+CRT94A6wvW0Fd=kzXssa=TDxvLJw=FPYf47yOqYsA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Add numeric_trim(numeric) (Dean Rasheed <dean.a.rasheed@gmail.com>) |
Список | pgsql-hackers |
On 6 January 2016 at 15:21, Dean Rasheed <dean.a.rasheed@gmail.com> wrote: > Actually I found the implementation a little confusing, partly because > the first comment doesn't really match the line of code that follows > it, and partly because of the complexity of the loop, the macros and > working out all the exit conditions from the loop. A much simpler > implementation would be to first call strip_var() ... Additionally, the central part of the algorithm where it computes dig % 10, dig % 100 and dig % 1000 inside a bunch of conditional macros is overly complex and hard to read. Once you've got it down to the case where you know dig is non-zero, you can just do while ((dig % 10) == 0) { dscale--; dig /= 10; } which works for any NBASE, rather than having to introduce an NBASE-dependent block of code with all those preprocessor conditionals. (Actually, given the other thread of this discussion, I would name that local variable min_scale now.) Regards, Dean
В списке pgsql-hackers по дате отправления: