Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version

From: Pedro Gimeno <pgsql-004(at)personal(dot)formauri(dot)es>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, rschaaf(at)commoninf(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Date: 2015-03-25 18:27:35
Message-ID: 5512FE17.6020702@personal.formauri.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote, On 2015-03-25 18:57:
> Hmm ... I'm thinking we probably should explicitly check for inf and NaN,
> no?
>
> if (isnan(x) || isinf(x))
> return x;
>
> It's possible the given coding would return this result anyway by
> accident, but that seems rather fragile.

I agree about NaN; it worked but mostly by accident. The big number
detection catches infinity unambiguously. Added to a comment in the
attached (plus corresponding tests).

Attachment Content-Type Size
nearest_or_even_d5.c text/x-csrc 5.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-03-25 19:57:34 Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version
Previous Message Tom Lane 2015-03-25 17:57:53 Re: Re: BUG #12885: The result of casting a double to an integer depends on the database version