On 2018-Dec-06, Gavin Flower wrote:
> Calculators normally work in floating point (in fact, as far as I am aware,
> they never work in integer mode by default),
The reason they don't work in "integer mode" is because it doesn't make
sense.
We only have this thing called "integer division" becaus
On 06/12/2018 02:32, Adrian Klaver wrote:
On 12/5/18 4:45 AM, Gavin Flower wrote:
On 06/12/2018 00:05, Geoff Winkless wrote:
On Wed, 5 Dec 2018 at 09:13, Gavin Flower
wrote:
SELECT ceil(10/4.0);
Geoff
If you divide one integer by another, then it is logical to get an
integer as as the an
I take the point that two decades of backward compatibility should and will
win. That said, it's an easy enough thing to right the balance for novices and
put in a really obvious place in the documentation what you should do if you
want to divide two integers and get the results with the number
Geoff Winkless writes:
> IMO it's fundamentally broken that SQL doesn't cast the result of a
> divide into a numeric value - the potential for unexpected errors
> creeping into calculations is huge; however that's the standard and
> no-one's going to change it now.
> Having said that it's worth no
On Wed, Dec 5, 2018 at 7:55 AM Geoff Winkless wrote:
> Where's the logical progression in step 3 here:
>
> 1 You asked the computer a question
>
> 2 The values you passed to it don't have decimal points
>
> ...
>
> 4 Ergo, you wanted an answer that was incorrect.
>
Well put. However the nature
On 12/5/18 4:45 AM, Gavin Flower wrote:
On 06/12/2018 00:05, Geoff Winkless wrote:
On Wed, 5 Dec 2018 at 09:13, Gavin Flower
wrote:
SELECT ceil(10/4.0);
Geoff
If you divide one integer by another, then it is logical to get an
integer as as the answer.
Hmm, grab any of my calculators and
On Wed, 5 Dec 2018 at 12:45, Gavin Flower wrote:
> If you divide one integer by another, then it is logical to get an
> integer as as the answer.
Hmm. It might fit with what a computer scientist might expect (or
rather, not be surprised about), but I don't think you can say that
it's "logical".
On 06/12/2018 00:05, Geoff Winkless wrote:
On Wed, 5 Dec 2018 at 09:13, Gavin Flower wrote:
SELECT ceil(10/4.0);
Is what you want for that example.
Except that implies that "number of people who can fit in a car" is a
real number, not a whole.
IMO it's fundamentally broken that SQL doesn't c
On Wed, 5 Dec 2018 at 09:13, Gavin Flower wrote:
> SELECT ceil(10/4.0);
>
> Is what you want for that example.
Except that implies that "number of people who can fit in a car" is a
real number, not a whole.
IMO it's fundamentally broken that SQL doesn't cast the result of a
divide into a numeric
On 05/12/2018 20:07, Rob Sargent wrote:
On Dec 4, 2018, at 9:33 PM, Gavin Flower wrote:
On 05/12/2018 10:51, Rob Sargent wrote:
On 12/4/18 2:36 PM, Martin Mueller wrote:
It worked, and I must have done something wrong. I'm probably not the only
person who would find something like the fol
> On Dec 4, 2018, at 9:33 PM, Gavin Flower
> wrote:
>
>> On 05/12/2018 10:51, Rob Sargent wrote:
>>
>>> On 12/4/18 2:36 PM, Martin Mueller wrote:
>>> It worked, and I must have done something wrong. I'm probably not the only
>>> person who would find something like the following helpful:
>>
On 05/12/2018 10:51, Rob Sargent wrote:
On 12/4/18 2:36 PM, Martin Mueller wrote:
It worked, and I must have done something wrong. I'm probably not the
only person who would find something like the following helpful:
division (integer division truncates the result) 10/3 3
The math ty
On 12/4/18 2:36 PM, Martin Mueller wrote:
It worked, and I must have done something wrong. I'm probably not the only
person who would find something like the following helpful:
division (integer division truncates the result)10/33
The math types might take offense here, with th
Martin Mueller schrieb am 04.12.2018 um 21:57:
I didn't formulate my question properly, because the query went like
"select alldefects /wordcount"
where alldefects and wordcount are integers.
But none of the different ways of putting the double colon seemed to
work.
One way is to make one
e. If you didn't know the root form, the dictionary was
no use.
In this, single stop shopping for the three most common problems of simple
division makes life easier for users.
On 12/4/18, 3:06 PM, "David G. Johnston" wrote:
On Tue, Dec 4, 2018 at 1:57 PM Martin Muell
Am 04.12.18 21:57 schrieb(en) Martin Mueller:
I didn't formulate my question properly, because the query went like
"select alldefects /wordcount"
where alldefects and wordcount are integers.
test=# create table xxx(alldefects bigint, wordcount bigint);
CREATE TABLE
test=# insert into xxx value
Use CAST() instead of ::.
SELECT CAST(alldefects AS NUMEREIC(10,4))/wordcount;
On 12/04/2018 02:57 PM, Martin Mueller wrote:
I didn't formulate my question properly, because the query went like
"select alldefects /wordcount"
where alldefects and wordcount are integers. But none of the diffe
On Tue, Dec 4, 2018 at 1:57 PM Martin Mueller
wrote:
>
> I didn't formulate my question properly, because the query went like
> "select alldefects /wordcount"
> where alldefects and wordcount are integers. But none of the different ways
> of putting the double colon seemed to work.
IDK...the
I didn't formulate my question properly, because the query went like
"select alldefects /wordcount"
where alldefects and wordcount are integers. But none of the different ways
of putting the double colon seemed to work.
The Postgres notation of this simple procedure is very unintuitive. I ha
On Tue, Dec 4, 2018 at 1:38 PM Joshua D. Drake wrote:
> I may be misunderstanding the question but:
Indeed...
> select cast(x/y as numeric(10,4));
Your answer is 2.0 instead of the correct 2.5 - you need to cast
before the division, not after.
David J.
On Tue, Dec 4, 2018 at 1:29 PM Martin Mueller
wrote:
> I have asked this question before and apologize for not remembering it. How
> do you do simple division in postgres and get 10/4 with decimals?
> This involves cast and numeric in odd ways that are not well explained in the
> d
Martin Mueller schrieb am 04.12.2018 um 21:29:
I have asked this question before and apologize for not remembering
it. How do you do simple division in postgres and get 10/4 with
decimals?
In the expression 10/4 both numbers are integers.
And an integer divsion does not yield decimals (that
From: Martin Mueller
Sent: Tuesday, December 4, 2018 3:30 PM
To: pgsql-general
Subject: simple division
I have asked this question before and apologize for not remembering it. How do
you do simple division in postgres and get 10/4 with decimals?
This involves cast and numeric in odd ways
On 12/4/18 12:29 PM, Martin Mueller wrote:
I have asked this question before and apologize for not remembering
it. How do you do simple division in postgres and get 10/4 with decimals?
This involves cast and numeric in odd ways that are not well explained
in the documentation. For instance
I have asked this question before and apologize for not remembering it. How do
you do simple division in postgres and get 10/4 with decimals?
This involves cast and numeric in odd ways that are not well explained in the
documentation. For instance, you’d expect an example in the Mathematical
25 matches
Mail list logo