From: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Joseph Koshakow <koshy44(at)gmail(dot)com>, "Gregory Stark (as CFM)" <stark(dot)cfm(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Infinite Interval |
Date: | 2023-03-28 13:43:54 |
Message-ID: | CAExHW5stdWJo6PA+Wq_F8w7=u29DPsrf09Y=zjp1gPVJMQoGzw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Mar 26, 2023 at 1:28 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> I think you can take it as read that simple C test programs on modern
> platforms will exhibit IEEE-compliant handling of float infinities.
>
For the record, I tried the attached. It gives a warning at compilation time.
$gcc float_inf.c
float_inf.c: In function ‘main’:
float_inf.c:10:17: warning: division by zero [-Wdiv-by-zero]
10 | float inf = 1.0/0;
| ^
float_inf.c:11:20: warning: division by zero [-Wdiv-by-zero]
11 | float n_inf = -1.0/0;
| ^
$ ./a.out
inf = inf
-inf = -inf
inf + inf = inf
inf + -inf = -nan
-inf + inf = -nan
-inf + -inf = -inf
inf - inf = -nan
inf - -inf = inf
-inf - inf = -inf
-inf - -inf = -nan
float 0.0 equals 0.0
float 1.0 equals 1.0
5.0 * inf = inf
5.0 * - inf = -inf
5.0 / inf = 0.000000
5.0 / - inf = -0.000000
inf / 5.0 = inf
- inf / 5.0 = -inf
The changes in the patch are compliant with the observations above.
--
Best Wishes,
Ashutosh Bapat
Attachment | Content-Type | Size |
---|---|---|
float_inf.c | text/x-csrc | 988 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2023-03-28 13:47:48 | Re: Infinite Interval |
Previous Message | Erik Rijkers | 2023-03-28 13:40:24 | Re: SQL/JSON revisited |