dc(1) bugs

Lowell Gilbert freebsd-questions-local at be-well.ilk.org
Wed Jan 13 19:10:38 UTC 2016

"CK" <nibbana at gmx.us> writes:

> FreeBSD-9.3 dc(1)
> These appear to be bugs to me, but please verify if possible:
> #####
> #####
> $ 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

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.

More information about the freebsd-questions mailing list