From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
Cc: | Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Add numeric_trim(numeric) |
Date: | 2016-01-07 08:52:59 |
Message-ID: | CAEZATCWE+CRT94A6wvW0Fd=kzXssa=TDxvLJw=FPYf47yOqYsA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 6 January 2016 at 15:21, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2016-01-07 09:05:03 | Re: Getting sorted data from foreign server for merge join |
Previous Message | Craig Ringer | 2016-01-07 08:45:30 | Re: pglogical - logical replication contrib module |