From owner-freebsd-questions@freebsd.org Wed Jan 13 19:10:38 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCDDCA80989 for ; Wed, 13 Jan 2016 19:10:38 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: from be-well.ilk.org (be-well.ilk.org [23.30.133.173]) by mx1.freebsd.org (Postfix) with ESMTP id AF8B51BFB for ; Wed, 13 Jan 2016 19:10:38 +0000 (UTC) (envelope-from freebsd-questions-local@be-well.ilk.org) Received: by be-well.ilk.org (Postfix, from userid 1147) id 4729333C25; Wed, 13 Jan 2016 14:01:53 -0500 (EST) From: Lowell Gilbert To: "CK" Cc: Subject: Re: dc(1) bugs References: <0McVKy-1aajq60oIS-00Hgju@mail.gmx.com> Reply-To: Date: Wed, 13 Jan 2016 14:01:53 -0500 In-Reply-To: <0McVKy-1aajq60oIS-00Hgju@mail.gmx.com> (CK's message of "Tue, 12 Jan 2016 19:23:36 -0900") Message-ID: <444mehe21q.fsf@be-well.ilk.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2016 19:10:38 -0000 "CK" writes: > FreeBSD-9.3 dc(1) > > These appear to be bugs to me, but please verify if possible: > > ##### > FIRST > ##### > $ dc -xe '50k16o16i.1vp' > 0 > $ dc -xe '50k10o16i.1vp' > 0 > $ dc -xe '50k10o10i.1vp' > 31622776601683793319988935444327185337195551393252 > > This should be telling dc(1): > > a) scale is 50 (in decimal) digits. > b) output in base16, base10, and base10 respectively. > c) input will be in base16, base16, and base10 respectively. > d) take the square root, and print it to the display. > > Of course, the 3rd example above is correct, but the first 2? Why 0? I don't have the sources at hand, so I can't comment on "why" at the moment. The first two can be simplified to '16i.1p' while still demonstrating the problematic behaviour. So neither scale, output base, or square root are relevant. Your other examples probably have the same cause, I suspect (although some of them give different results, including decimal points, on my RELENG_10 system). Interestingly, the Gnu implementation seems to give the same results, so there may be something that you (and I) don't know about in the dc specification. That would probably have to deal with fractions in input numbers, which isn't discussed in the dc(1) manual. Seems unlikely, though, based on the fact that a radix smaller than 10 does what I expect and one larger does not.