Re: [PATCH] Fix overflow and underflow in regr_r2()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Chengpeng Yan <chengpeng_yan(at)outlook(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Fix overflow and underflow in regr_r2()
Date: 2026-05-16 21:18:43
Message-ID: 1524050.1778966323@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> I just had a thought: a simpler (and probably faster and more
> accurate) solution would be to use frexp() and ldexp(), which are both
> part of C99, so ought to be OK.

Seems like a plan. We're already relying on ldexp() in pg_prng.c,
so I doubt there's a portability issue. Reading the man page for
frexp(), we might want to special-case Inf and NaN inputs to avoid
assuming what it will do with those. But that would only be needed
in the slow path where we're recovering from overflow/underflow.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-05-16 23:00:43 Re: Simplify signature of ProcessStartupPacket()
Previous Message Dean Rasheed 2026-05-16 20:34:25 Re: [PATCH] Fix overflow and underflow in regr_r2()