Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gURHV-0003tR-Tl for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 07:07:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gURHS-0001al-Ry for pgsql-general@arkaria.postgresql.org; Wed, 05 Dec 2018 07:07:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gURHS-0001ab-Ht for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 07:07:34 +0000 Received: from mail-it1-x132.google.com ([2607:f8b0:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gURHL-0008DS-50 for pgsql-general@lists.postgresql.org; Wed, 05 Dec 2018 07:07:33 +0000 Received: by mail-it1-x132.google.com with SMTP id h193so18665695ita.5 for ; Tue, 04 Dec 2018 23:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=jrtZS9NH7/3UxRC7C82jaZbw6JWbpHwCWy9EhsxBCu0=; b=HK97OUkf9xT1iqRhlSc8kdv7ANW9qbGp/+XVZaaeAGL9fiGtdTPhwqeCcZ9WUvewWn YDyL4gZdkmU4eSmQw1DuAFO6KtOXJC7FSJYeRKhUccoYJdaw2jo3EFFBFzEu9wf02tsl XMs7v+lQhhh4LOb0hD90VTEizp3emuwvIZuDLRegqw0grHriJwct28gsIvCjWqUEW02u EymNK7eGq41ssx/IRZya2Q/fFgiocC3f7FutkXuTjj0C9osOkOY0gtSMVR2h6oFaL8QI Ot7t7y8sOWSMbRp/Ddfdfkxap07t23NpPz674O7u7hJKH1b33VqNsahxKyjbHlMve04C z1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=jrtZS9NH7/3UxRC7C82jaZbw6JWbpHwCWy9EhsxBCu0=; b=oRVe1NcUWeclLNPWdCKkYBiRcXqpKR/2388Lvt4nGtBhA3HwgjVWuUgXAhVCHgAlOE FgqkJH1AbfkdmSkz0jlm3P/9MncS/bJnZEWetwqFwk28tWxZycbLEKqUuyVJfjNxXiY/ s8GmHDEdir/kajTnHMsew294VLE7OlEdz5faLibqDeGsw1gndAL9y1TRKESuA7A+WRd+ ZTeUxsTMYDSNnd6HHJ18cLE39SrsEj3WZvTjnHh+K8dr7hepemo5ws26gX42lYEYSJip S+bmE71HO1o/N4s6QOyc5yiKAaIj63QM3OPyw9oXsSA1WfDhScokwQBS2hvisHDB4kyX PUkw== X-Gm-Message-State: AA+aEWZM6JMwrYQzsbtVMXZ4colM5EJgSsP2YxIKsAv3oWoaNp7JDsJa nytkbSwihsI2qTFbyAGGc80L/sO/ X-Google-Smtp-Source: AFSGD/U1QQ2EbJe9CXXpLhPxJZsoOG5FRh7BCZYQ3AB9PhEyoxzrzXGu99ga6+W/jtc3Nw2b1OvVZg== X-Received: by 2002:a02:b015:: with SMTP id p21mr21924813jah.17.1543993643646; Tue, 04 Dec 2018 23:07:23 -0800 (PST) Received: from ?IPv6:2601:681:5500:1e3c:3dc2:5e35:b279:6f1e? ([2601:681:5500:1e3c:3dc2:5e35:b279:6f1e]) by smtp.gmail.com with ESMTPSA id t64sm6916501itb.5.2018.12.04.23.07.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 23:07:22 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: simple division From: Rob Sargent X-Mailer: iPhone Mail (16B92) In-Reply-To: <611dee86-118f-df30-a942-2441fc04668f@archidevsys.co.nz> Date: Wed, 5 Dec 2018 00:07:21 -0700 Cc: pgsql-general@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <59110313-9F31-4D7F-BAAC-4223EE751CC7@gmail.com> References: <4DEACFC2-E8E3-4C61-805B-56A5F76CB819@northwestern.edu> <8B35EF9C-8DEF-4298-A646-89D1AC8F63E1@northwestern.edu> <1F5FCEFC-7DEA-46FA-9895-FBF7DFDEC750@northwestern.edu> <627868ba-0d4b-8995-d29a-db6b7ca3673d@gmail.com> <611dee86-118f-df30-a942-2441fc04668f@archidevsys.co.nz> To: Gavin Flower List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Dec 4, 2018, at 9:33 PM, Gavin Flower w= rote: >=20 >> On 05/12/2018 10:51, Rob Sargent wrote: >>=20 >>> On 12/4/18 2:36 PM, Martin Mueller wrote: >>> It worked, and I must have done something wrong. I'm probably not the on= ly person who would find something like the following helpful: >>>=20 >>>=20 >>> division (integer division truncates the result) 10/3 3 >>=20 >> The math types might take offense here, with the use of "truncates". Int= eger division really ask how many times can one subtract the numerator from t= he denominator without going negative (or how many times does the numerator "= go into" the denominator). >>=20 >> It may seem a nuisance, but int division is a useful construct and must b= e supported (and be the default). (If you have 10 people to transport in car= s which hold four (all can drive) 10/4 =3D 3 ;) ) >>=20 >>=20 >>=20 >>=20 > Hmm... >=20 > 10 / 4 =3D 2 >=20 And two are left stranded! The point is that integer math has its place. You cant have 2.5 cars. So 10= /4 in this context is 3.=20 More correctly the calculation is=20 10/4 + 10%4>0 ? 1 :0 =3D 3 (Maybe psql does have % so mod(10,4))