Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1Sfe-0006bS-6P for pgsql-docs@arkaria.postgresql.org; Sat, 03 Dec 2022 13:35:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p1Sfb-0006CL-8E for pgsql-docs@arkaria.postgresql.org; Sat, 03 Dec 2022 13:35:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p1Sfa-0006CA-KF for pgsql-docs@lists.postgresql.org; Sat, 03 Dec 2022 13:35:06 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p1SfU-000343-6d for pgsql-docs@lists.postgresql.org; Sat, 03 Dec 2022 13:35:05 +0000 Received: by mail-ed1-x52d.google.com with SMTP id v8so9904630edi.3 for ; Sat, 03 Dec 2022 05:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=B+VX0Us7BMCRAyEToj9E3kSvJkY9iUJESl5lbwE24oE=; b=bbEcqtYaU8RnAHL4hLhWZFCDqCeTbAo+jB1APRA26FYNqh5NzNbkMTvUd8Fjjp4o5c w9y/S5VH+zvQtcpcWeQt+OcH2EHAPVSqulWAiDhUiVRcO/wBbeXVsdjWZ+b/wrxvHG/U v+ObX/OoAv2wZiVmomztXk0WyNCOW95VIGw2258q8/FjFoKG3cc08fKSWmVu31mgnoMq 3cUTPpWrLk/+27vz1A39OIqZnyXudXgDDIfvIWXIjIEnVeqDX+cW2CwiyjgXzt3FDCpA F4BL/DXFq2PKtDk6qSs+cvgWwUEM4H8T9BlKzbtmMtyNjyAdWEvuRRQpCfNXTZpGUywI jRbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=B+VX0Us7BMCRAyEToj9E3kSvJkY9iUJESl5lbwE24oE=; b=7e8dg+q6118JOLXicTruaVVAKOnbbNdB9cp7e0qVKZscpz70vyBU4pRjC606/ZUGlj PbcFS4RKSbbhCeBuLTchOQitu1oo5L4aYehWUAYwQNGnvVB92BXbYkDISNI2vhkaOYfC tKAAR9bF7mf6JOkyDWjDpPwKxjJGMZwee9bv2kSiHaMQN9JT6+E4WSLLP35JWaqPLurS JutYx1Sy28WJWFOdZeqiNQ3qUkYeDI83dORVkyaqlXp+oKrQUc1vuVVhnOyVjQB2UVXd sK2nmo6mz8XFLNL1oIb244NVqDwq6Z1AmqOB67UaHO87h6VV6bUkRUfksxtT0rPBjTjV aZ9w== X-Gm-Message-State: ANoB5pkbzKkKjI1mPaWpMoAd216lgEFgdsMSnvxTVHQVMby4BTr/xHE6 BZTyV4Hg15ZUeH8owZncT0Ywig== X-Google-Smtp-Source: AA0mqf6D78yDGK8o5PXT9fMjx21H3LvjwvQMVkrEqMK9o6EDzmfVnEUBdoSXWCcva4Hst1o7Xp/oAA== X-Received: by 2002:a05:6402:e97:b0:461:beb2:76e with SMTP id h23-20020a0564020e9700b00461beb2076emr66568068eda.5.1670074498266; Sat, 03 Dec 2022 05:34:58 -0800 (PST) Received: from localhost.localdomain (178-190-172-51.adsl.highway.telekom.at. [178.190.172.51]) by smtp.gmail.com with ESMTPSA id es15-20020a056402380f00b0046aa78ecd8asm4086253edb.3.2022.12.03.05.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 05:34:57 -0800 (PST) Message-ID: <3da3dcc06220f80537dc1fb2c32cb76c91f87b93.camel@cybertec.at> Subject: Re: Explanation of the ROUND function with NUMERIC as an argument From: Laurenz Albe To: kamiya33hirokazu@gmail.com, pgsql-docs@lists.postgresql.org Date: Sat, 03 Dec 2022 14:34:56 +0100 In-Reply-To: <167005767233.1899.2490889277144246641@wrigleys.postgresql.org> References: <167005767233.1899.2490889277144246641@wrigleys.postgresql.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2022-12-03 at 08:54 +0000, PG Doc comments form wrote: > Explanation of the manual's ROUND function > round ( numeric ) → numeric > round ( double precision ) → double precision > Rounds to nearest integer. For numeric, ties are broken by rounding away > from zero. For double precision, the tie-breaking behavior is platform > dependent, but “round to nearest even” is the most common rule. > round(42.4) → 42 > > Operation of the ROUND function > postgres=# SELECT round(CAST(42.5 AS numeric)); >  round > ------- >     43 > (1 row) > > I am thinking that the value of the ROUND function with NUMERIC as an > argument is rounded off, not rounded away from zero. It is rounded away from zero, since 43 is farther away from 0 than 42.5. This may be a language problem. Yours, Laurenz Albe