Date: Wed, 13 Jan 2016 14:01:53 -0500 From: Lowell Gilbert <freebsd-questions-local@be-well.ilk.org> To: "CK" <nibbana@gmx.us> Cc: <freebsd-questions@freebsd.org> Subject: Re: dc(1) bugs Message-ID: <444mehe21q.fsf@be-well.ilk.org> In-Reply-To: <0McVKy-1aajq60oIS-00Hgju@mail.gmx.com> (CK's message of "Tue, 12 Jan 2016 19:23:36 -0900") References: <0McVKy-1aajq60oIS-00Hgju@mail.gmx.com>
next in thread | previous in thread | raw e-mail | index | archive | help
"CK" <nibbana@gmx.us> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?444mehe21q.fsf>