Re: integer instead of 'double precision'?

From: Willy-Bas Loos <willybas(at)gmail(dot)com>
To: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Cc: Henry Drexler <alonup8tb(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: integer instead of 'double precision'?
Date: 2012-11-12 13:16:21
Message-ID: CAHnozTi+Hf2A_TyUD_LqjyWXYCJUvX_LJg=4oqS+n447MUvWfw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 9, 2011 at 5:09 PM, Guillaume Lelarge <guillaume(at)lelarge(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2012-11-12 13:39:34 Re: integer instead of 'double precision'?
Previous Message Velislav Stoychev 2012-11-12 12:50:43 FATAL: sorry, too many clients already when I start the replication