Skip site navigation (1) Skip section navigation (2)

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

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>, Roman Kononov <kononov195-pgsql(at)yahoo(dot)com>
Subject: Re: [BUGS] BUG #2846: inconsistent and confusing
Date: 2006-12-27 21:35:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > I have made some more progress on this patch.
> I'm not convinced that you're fixing things so much as doing your best
> to destroy IEEE-compliant float arithmetic behavior.
> I think what we should probably consider is removing CheckFloat4Val
> and CheckFloat8Val altogether, and just letting the float arithmetic
> have its head.  Most modern hardware gets float arithmetic right per
> spec, and we shouldn't be second-guessing it.

Well, I am on an Xeon and can confirm that our computations of large
non-infinite doubles who's result greatly exceed the max double are
indeed returning infinity, as the poster reported, so something isn't
working, if it supposed to.  What do people get for this computation?

	#include <stdio.h>
	#include <stdlib.h>
	main(int argc, char *argv[])
		double a = 1e300, b = 1e300;
		double c;
		c = a * b;
		printf("%e\n", c);
		return 0;

I get 'inf'.  I am on BSD and just tested it on Fedora Core 2 and got
'inf' too.

> A slightly less radical proposal is to reject only the case where
> isinf(result) and neither input isinf(); and perhaps likewise with
> respect to NaNs.

Uh, that's what the patch does for 'Inf':

    result = arg1 + arg2;
    CheckFloat4Val(result, isinf(arg1) || isinf(arg2));

I didn't touch 'Nan' because that is passed around as a value just fine
--- it isn't created or tested as part of an overflow.

  Bruce Momjian   bruce(at)momjian(dot)us

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

In response to


pgsql-hackers by date

Next:From: David FetterDate: 2006-12-27 21:38:41
Subject: Re: Per-database search_path
Previous:From: Simon RiggsDate: 2006-12-27 21:34:04
Subject: Re: xlog directory at initdb time

pgsql-patches by date

Next:From: Simon RiggsDate: 2006-12-27 21:36:23
Subject: Re: WIP patch for "operator families"
Previous:From: Simon RiggsDate: 2006-12-27 21:34:04
Subject: Re: xlog directory at initdb time

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group