**Subject:** Re: replacement for bc(1), dc(1), diff(1), and diff(3)

**To:** Phil Nelson *<phil@cs.wwu.edu>*

**From:** Otto Moerbeek *<otto@drijf.net>*

**List:** tech-userlevel

**Date:** 03/27/2005 21:54:43
On Sun, 27 Mar 2005, Phil Nelson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sunday 27 March 2005 07:24, Phil Nelson wrote:
> > On Sunday 27 March 2005 04:11, you wrote:
> > > That's 68 digits, a backslash and 3 digits.
> > > Line lenght is 69
> >
> > You are right. GNU bc is wrong.
>
> Well, after thinking about this for a while, I went back to the ChangeLog and
> found a change in March of 1995 where I changed the line length to 68
> numbers, the backslash and then the linefeed for a total of 70 characters. I
> was convinced by someone else that POSIX line lengths include the linefeed.
> My first implementation did it the same way that your bc does it.
>
Note that your dc and bc do not agree (I know that POSIX says nothing
about dc, but I'd expect the two to behave the same):
om@xs3:~$ bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
10^70
10000000000000000000000000000000000000000000000000000000000000000000\
000
om@xs3:~$ dc # this is GNU dc
10 70 ^p
100000000000000000000000000000000000000000000000000000000000000000000\
00
Apart form the question whether line feeds should be counter or not,
there's this corner case:
10 69 ^p
1000000000000000000000000000000000000000000000000000000000000000000000
10 69 ^p
100000000000000000000000000000000000000000000000000000000000000000000\
0
In other words, should a number of exactly line max length be printed with
a line continuation or not? Seems kinda silly to have a line continuation
if what follows is only 1 extra char.
-Otto