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.92) (envelope-from ) id 1jA3Gt-0008KA-S5 for pgsql-docs@arkaria.postgresql.org; Fri, 06 Mar 2020 03:03:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jA3Gs-0006OI-73 for pgsql-docs@arkaria.postgresql.org; Fri, 06 Mar 2020 03:03:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jA3Gr-0006OA-PA for pgsql-docs@lists.postgresql.org; Fri, 06 Mar 2020 03:03:30 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jA3Gk-0005Z5-V2 for pgsql-docs@lists.postgresql.org; Fri, 06 Mar 2020 03:03:28 +0000 Received: by mail-pl1-x62a.google.com with SMTP id f8so241156plt.10 for ; Thu, 05 Mar 2020 19:03:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:in-reply-to:from:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=aI7eS/euoj70tIKqgCtMWehap+l3HW+CQvM9f9gArbQ=; b=Ytdg1MDtXUzB9KZz1NrolQgYxSb0qj88mC7allbitjhm8BJf3zBzy8rzKwhmxGsyOg FuKWH7SIIbYlHlwgv3F6lmy3FqiCYrUmerZHOvANi1cZxMRbE++kh+UPROB+JHiPQ9Cw rErAKIYn0CtntGVZp7l0ytm6SPauASC4Fc02aJiAiL1sUnziagtVFByAoSa9MCCehvHn amxKNhoe73kfRUg7+E4vW4tR/lmVPpjCVSqCJLd7bzGwe4uMDmDXw//eEBBAiAKrjArm JkMvHgSgd8V8EgrY5xUlkOhvkJ0NtNAHbFMs2Qztjx5qS3dQDKCxVjtYhWF54EWfziOl wkIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:in-reply-to:from :message-id:date:user-agent:mime-version:content-transfer-encoding :content-language; bh=aI7eS/euoj70tIKqgCtMWehap+l3HW+CQvM9f9gArbQ=; b=HOm7pYfyoKRCWZY57Qdfc/CRtNFRQmFrcuRfvtg/pRmrANuBNuPMKkCHjzFNfepno0 +CvkAAwXYVUsH/rLv+gINx2cGxqQYiuVR4RQIo9+RiOmDGU9I38AV560OosAWrr1h3Cb wGqZHmjdmG9wtzPVZpLyHDWlMDaHWFaxg3v3yJngaqoZ89X7LRDZ5Za7h/itkSzLqTwT RyCrGP875ntuZBFx7ZnIyHF1XbZ4l1Wz9wyPBiE3XokxNL6DxKWn0Kl37eTd8rpa67tH kTdqYorQLYa3vuWR28Q1Cw2S71rPwDwzikCHaQVVKwzxjX9yZIcDaa4V6ct+Sr1jDHCM imyQ== X-Gm-Message-State: ANhLgQ3PkhdkK0iXdrMvzN57KvP12sERQiqplDTrNQDrrV0xUdEOYtDX 24JcSIR/2g2a6/+jJkVI9z2Bbv1H X-Google-Smtp-Source: ADFU+vtQIXcnZRf9dyc3P79MwjIR3fzQn4CxGwZkaswwMCTHTB9lRCSQKLgSO05mQaZ0nIfqqgrZIQ== X-Received: by 2002:a17:90a:2551:: with SMTP id j75mr1240275pje.165.1583463801027; Thu, 05 Mar 2020 19:03:21 -0800 (PST) Received: from ?IPv6:2001:56a:7038:1700:fc0a:5af0:9ad5:db8b? (node-1w7jr9y4x4jwkiuut9qo1mg0b.ipv6.telus.net. [2001:56a:7038:1700:fc0a:5af0:9ad5:db8b]) by smtp.gmail.com with ESMTPSA id d24sm35233158pfq.75.2020.03.05.19.03.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 05 Mar 2020 19:03:20 -0800 (PST) Subject: Re: Incomplete or misleading explanation of the data types for mathematical operators To: Bruce Momjian , pgsql-docs@lists.postgresql.org References: <158032651854.19851.16261832706661813796@wrigleys.postgresql.org> <20200306022912.GB10548@momjian.us> In-Reply-To: <20200306022912.GB10548@momjian.us> From: Sergei Agalakov Message-ID: <4d9d1083-b876-f90c-ace6-95df64153ecb@gmail.com> Date: Thu, 5 Mar 2020 20:03:19 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/5/2020 7:29 PM, Bruce Momjian wrote: > On Wed, Jan 29, 2020 at 07:35:18PM +0000, PG Doc comments form wrote: >> The following documentation comment has been logged on the website: >> >> Page: https://www.postgresql.org/docs/12/functions-math.html >> Description: >> >> "The bitwise operators work only on integral data types, whereas the others >> are available for all numeric data types. " >> Many math operators silently convert integral data types to double for >> calculations, so the result will not be the same data type as what was >> provided. >> select pg_typeof(10^2::bigint),pg_typeof(10^2::numeric) >> select pg_typeof(|/25::int), pg_typeof(|/25::numeric) >> select pg_typeof(10*10::bigint), pg_typeof(10*10::numeric) >> >> Multiplication preserves data type, exponentiation silently converts bigint >> to double, but preserves numeric data type, square root silently converts >> both int and numeric types to double. >> The best would be to explain this behaivior of operators like it was done >> for mathematical functions. > Uh, how does this relate to bitwise operators? Why would we mention > type changes for things like exponentiation in the bitwise operator > documentation section? > This chapter is named "Mathematical Functions and Operators". The table 9.4. is named "Mathematical Operators". I don't see on this page any section "Bitwise operators" so I don't really understand your complaint. How do you understand the phrase "The bitwise operators work only on integral data types, whereas the others are available for all numeric data types. "  in the context of the table "Mathematical Operators"? I understand it that all other mathematical operators except bitwise operators do exist for all numeric data type. In what place by your opinion documentation should describe that some mathematical operators exist only for some numeric data types but not others? I have given examples of such operators - exponentiation and square root aren't defined for all numeric data types and do hidden conversion of the data types.