Re: Divide a float4 by 1 - what is going on???????

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Daniel Schuchardt <daniel_schuchardt(at)web(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Divide a float4 by 1 - what is going on???????
Date: 2005-09-17 00:43:14
Message-ID: 20050917004314.GA2817@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Sep 17, 2005 at 02:12:45AM +0200, Daniel Schuchardt wrote:
> CIMSOFT=# SELECT n1/1 FROM test;
> ?column?
> ------------------
> 2.45667695999146
> (1 row)
>
> Why I get so many digits by a division with one? Anybody should have
> learned that everything / 1 = everything ;-)

Looks like the division is being done in double precision (float8)
and you're seeing the effects of an inexact representation.

test=> SELECT 2.456677::real / 1;
?column?
------------------
2.45667695999146
(1 row)

test=> SELECT 2.456677::real / 1::real;
?column?
----------
2.45668
(1 row)

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moseley 2005-09-17 01:10:46 Re: Setting WHERE on a VIEW with aggregate function.
Previous Message Dann Corbit 2005-09-17 00:43:06 Re: Divide a float4 by 1 - what is going on???????