Re: Some improvements to numeric sqrt() and ln()

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: nospam-pg-abuse(at)bloodgate(dot)com
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Some improvements to numeric sqrt() and ln()
Date: 2020-03-03 13:42:20
Message-ID: CAEZATCWi1+8ExgPLk=bpEC=jxzjM5Bzch20nfhF7UaQWCC5dhQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 3 Mar 2020 at 00:17, Tels <nospam-pg-abuse(at)bloodgate(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2020-03-03 14:33:15 Re: Identifying user-created objects
Previous Message Hamid Akhtar 2020-03-03 13:07:10 Re: Minor issues in .pgpass