Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B45A9B5DBC1 for ; Thu, 23 Jun 2011 07:42:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 26928-01 for ; Thu, 23 Jun 2011 10:41:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by mail.postgresql.org (Postfix) with ESMTP id 3697AB5D91F for ; Thu, 23 Jun 2011 07:41:59 -0300 (ADT) Received: from mail-wy0-f174.google.com (mail-wy0-f174.google.com [74.125.82.174]) (authenticated bits=0) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p5NAfuKE005654 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL) for ; Thu, 23 Jun 2011 03:41:57 -0700 Received: by wyb38 with SMTP id 38so1189116wyb.19 for ; Thu, 23 Jun 2011 03:41:56 -0700 (PDT) Received: by 10.216.62.195 with SMTP id y45mr1940830wec.15.1308825716086; Thu, 23 Jun 2011 03:41:56 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.189.167 with HTTP; Thu, 23 Jun 2011 03:41:26 -0700 (PDT) In-Reply-To: References: From: Thom Brown Date: Thu, 23 Jun 2011 11:41:26 +0100 Message-ID: Subject: Re: Functions example results incorrect To: pgsql-docs Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/88 X-Sequence-Number: 6862 On 23 June 2011 10:46, Thom Brown wrote: > I've been looking at some of the functions listed in the docs and > noticed some apparent discrepancies. > > This page of the docs doesn't seem to match real output for exp or ln: > http://www.postgresql.org/docs/9.0/static/functions-math.html > > It says that exp(1.0) yields 2.71828182845905. > > Testing on 3 different systems shows an answer with two more > significant figures: 2.7182818284590452 > > The same for ln(2.0), which the example gives as 0.693147180559945, > but for me it's 0.6931471805599453. > > And sqrt(2.0) has the example output of 1.4142135623731, but I get > 1.414213562373095. > > For log(100.0), the output is 2, which doesn't match the definition > since it claims the return type should be the same as the input, which > in this case it clearly isn't. =A0Trying this out returns > 2.0000000000000000. > > The log function for which the base is passed, and the type of which > should always be numeric shows an example output for log(2.0, 64.0) as > 6.0000000000. =A0My output returns 6.0000000000000000, so 6 extra > digits. > > The power function appears on 2 lines showing that it accepts double > precision or numeric. =A0The double precision example appears to be > wrong because it will be assumed the value is double precision unless > the value is explicitly cast. =A0In either case, the output wouldn't > have zero decimal places as shown in the example output. > > Also, on the string functions page > (http://www.postgresql.org/docs/9.0/static/functions-string.html), the > output for the decode example shows an escape formatted output. =A0This > isn't the case by default in 9.0, so that should be changed, and maybe > a reference to a page explaining how the output depends on the > configuration of bytea_output. > > The quote literal example of quote_literal('O\'Reilly') doesn't work > on my installation by default. =A0It assumes I'm using a client encoding > that allows backslash within a multibyte character and that I have > backslash_quote set to safe_encoding. > > Can someone confirm whether these are valid complaints? The same non-default bytea output representations are also shown on all examples on http://www.postgresql.org/docs/9.0/static/functions-binarystring.html where bytea is the output type. --=20 Thom Brown Twitter: @darkixion IRC (freenode): dark_ixion Registered Linux user: #516935 EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company