Re: integer instead of 'double precision'? - Mailing list pgsql-general

From Willy-Bas Loos
Subject Re: integer instead of 'double precision'?
Date
Msg-id CAHnozTi+Hf2A_TyUD_LqjyWXYCJUvX_LJg=4oqS+n447MUvWfw@mail.gmail.com
Whole thread Raw
In response to Re: integer instead of 'double precision'?  (Guillaume Lelarge <guillaume@lelarge.info>)
Responses Re: integer instead of 'double precision'?  (Chris Angelico <rosuav@gmail.com>)
Re: integer instead of 'double precision'?  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
On Fri, Sep 9, 2011 at 5:09 PM, Guillaume Lelarge <guillaume@lelarge.info> wrote:
You divide an integer with an integer, that should give you an integer.

Can you tell me the reasoning behind that idea?
Is it a rule that the output type of an operator must equal the input type?
In this case that doesn't seem locigal. I think that the "/" operator should return something that allows fractions, since the operator creates fractions so frequently.
If you should need it to be an integer, e.g. when you update an integer column, casting should  be done just-in-time.

But i don't know much about the internals and the reasoning behind these matters, i would be grateful if you could explain.

Cheers,

WBL

--
"Quality comes from focus and clarity of purpose" -- Mark Shuttleworth

pgsql-general by date:

Previous
From: Ivan Voras
Date:
Subject: PostgreSQL and a clustered file system
Next
From: Chris Angelico
Date:
Subject: Re: integer instead of 'double precision'?