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