Re: pgsql: Ensure that numeric.c compiles with other NBASE values. - Mailing list pgsql-committers

From Dean Rasheed
Subject Re: pgsql: Ensure that numeric.c compiles with other NBASE values.
Date
Msg-id CAEZATCUZqhn1ZHvczW7TBFB75MT-aA5uZbNhNeU=atYWYb-BPw@mail.gmail.com
Whole thread Raw
In response to Re: pgsql: Ensure that numeric.c compiles with other NBASE values.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-committers
On Fri, 3 Feb 2023 at 01:18, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Dean Rasheed <dean.a.rasheed@gmail.com> writes:
>
> > 1). It doesn't work if log10val2 < 0, because then m < 0, and it
> > doesn't multiply by the remainder. And it then throws an overflow
> > error, because result.dscale comes out wrong when m < 0.
>
> I'm not quite sure that it's worth expending code space on the
> log10val2 < 0 case (compared to just "Assert(log10val2 >= 0").
> On the other hand, it's not much extra code, and committing it now
> might save somebody reinventing that logic in future.
>

Yeah, I thought about that, but it's hardly any code to support that
case. Also, this function is out there now (I found an example on
Stack Overflow of someone using it), so we have no control over how
people will use it in their own C code, and so I think it's worth
making it robust across the range of possible inputs.

Regards,
Dean



pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: pgsql: ci: Use windows VMs instead of windows containers
Next
From: Peter Eisentraut
Date:
Subject: pgsql: doc: Fix XML formatting that psql cannot handle