Re: [BUGS] BUG #2846: inconsistent and confusing handling of

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Roman Kononov <roman(at)xtremedatainc(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [BUGS] BUG #2846: inconsistent and confusing handling of
Date: 2006-12-27 21:23:39
Message-ID: 200612272123.kBRLNdg05533@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Roman Kononov wrote:
> On 12/27/2006 12:44 PM, Bruce Momjian wrote:
> > The only unsolved issue is the one with underflow checks. I have added
> > comments explaining the problem in case someone ever figures out how to
> > address it.
>
> This will behave better for float4:
>
> Datum float4pl(PG_FUNCTION_ARGS)
> {
> --- float4 arg1 = PG_GETARG_FLOAT4(0);
> --- float4 arg2 = PG_GETARG_FLOAT4(1);
> +++ double arg1 = PG_GETARG_FLOAT4(0);
> +++ double arg2 = PG_GETARG_FLOAT4(1);
> double result;
>
> result = arg1 + arg2;
> CheckFloat4Val(result,isinf(arg1) || isinf(arg2));
> PG_RETURN_FLOAT4((float4) result);
> }

Are you sure? As I remember, computation automatically upgrades to
'double'. See this program and output:

$ cat tst1.c
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
float a = 1e30, b = 1e30;
double c;

c = a * b;

printf("%e\n", c);
return 0;
}

$ tst1
1.000000e+60

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2006-12-27 21:24:06 Re: Load distributed checkpoint
Previous Message mark 2006-12-27 20:44:36 Re: Bitmap index thoughts

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2006-12-27 21:24:06 Re: Load distributed checkpoint
Previous Message Roman Kononov 2006-12-27 20:43:04 Re: [BUGS] BUG #2846: inconsistent and confusing handling of underflows,