Re: Some improvements to numeric sqrt() and ln() - Mailing list pgsql-hackers

From Dean Rasheed
Subject Re: Some improvements to numeric sqrt() and ln()
Date
Msg-id CAEZATCWi1+8ExgPLk=bpEC=jxzjM5Bzch20nfhF7UaQWCC5dhQ@mail.gmail.com
Whole thread Raw
In response to Re: Some improvements to numeric sqrt() and ln()  (Tels <nospam-pg-abuse@bloodgate.com>)
List pgsql-hackers
On Tue, 3 Mar 2020 at 00:17, Tels <nospam-pg-abuse@bloodgate.com> wrote:
>
> Thank you for these patches, these sound like really nice improvements.

Thanks for looking!

> One thing can to my mind while reading the patch:
>
> +        *              If r < 0 Then
> +        *                      Let r = r + 2*s - 1
> +        *                      Let s = s - 1
>
> This can be reformulated as:
>
> +        *              If r < 0 Then
> +        *                      Let r = r + s
> +        *                      Let s = s - 1
> +        *                      Let r = r + s
>
> which would remove one mul/shift and the temp. variable.

Good point, that's a neat little optimisation.

I wasn't able to detect any difference in performance, because those
corrections are only triggered about 1 time in every 50 or so, but it
looks neater to me, especially in the numeric iterations, where it
saves a sub_var() by const_one as well as not using the temporary
variable.

Regards,
Dean



pgsql-hackers by date:

Previous
From: Hamid Akhtar
Date:
Subject: Re: Minor issues in .pgpass
Next
From: vignesh C
Date:
Subject: Re: Identifying user-created objects