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

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

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Roman Kononov <kononov195-pgsql(at)yahoo(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 22:04:34
Message-ID: 200612272204.kBRM4Yw13461@momjian.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Roman Kononov wrote:
> On 12/27/2006 03:23 PM, Bruce Momjian wrote:
> > Are you sure?  As I remember, computation automatically upgrades to
> > 'double'.  See this program and output:
> 
> This is platform- and compiler- dependent:
> 
> ~>uname -a
> Linux rklinux 2.6.15-27-amd64-generic #1 SMP PREEMPT Fri Dec 8 17:50:54 UTC 2006 x86_64 GNU/Linux
> ~>gcc --version
> gcc (GCC) 4.3.0 20061213 (experimental)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> ~>cat test.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;
> }
> ~>gcc test.c
> ~>./a.out
> inf
> ~>gcc -march=i386 -m32 test.c
> ~>./a.out
> 1.000000e+60

Interesting.  I didn't know that, but in the float4pl() function,
because the overflow tests and result is float4, what value is there to
doing things as double --- as soon as the float4 maximum is exceeded, we
throw an error?

-- 
  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

pgsql-hackers by date

Next:From: David FetterDate: 2006-12-27 22:06:38
Subject: (SETOF) RECORD AS complex_type
Previous:From: Stephen FrostDate: 2006-12-27 22:02:23
Subject: Re: pg_hba.conf hostname todo

pgsql-patches by date

Next:From: Simon RiggsDate: 2006-12-27 22:07:56
Subject: Re: Load distributed checkpoint
Previous:From: Joshua D. DrakeDate: 2006-12-27 21:43:54
Subject: Re: [BUGS] BUG #2846: inconsistent and confusing

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