Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux