bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with _ in GNU dc


From: Charles Z Moss
Subject: problem with _ in GNU dc
Date: Sun, 25 May 2003 20:41:58 -0500

I have found what I consider to be a bug in GNU dc version 1.3.  While I was
writing my own rpn calculator (in Python), I was comparing the output of my
calculator with that of GNU dc.  When I implemented negative numbers, I came
across the following code, which I think behaves incorrectly (in GNU dc):

___++

This pushes three 0s, then adds the last two 0s pushed and pushes 0, then adds
the two 0s on the stack and pushes 0.  (This is, of course, just an 
example---any
number $n$ of underscores followed by $n-1$ +'s (or -, *, etc.) is valid.)  I
think the above code should produce, according to GNU dc's error output:

dc: stack empty
dc: stack empty

I.e., successive underscores should not push 0.  It would make more sense (to 
me)
that way, anyway.  I can, if you wish, attempt to modify the code to implement
the (again, to me) more sane behavior, but if you want it done soon, you 
should
probably do it yourself---I'm not much of a C programmer (yet).

I can not right now verify whether this behavior exists in any other
implementation of dc, but I do have access to some new iMac's with Mac OS X,
version 10.2.5, so if you'd like, I can check it's behavior (I'll check it
anyway, but if you want to know about it, tell me so (my guess is that it will 
be
the same behavior as would be exhibited on FreeBSD (but, unfortunately, I 
don't
have my FreeBSD box with me))).

Also, just so you know, I am using Cygwin (the latest version (as of about one
month ago)).

It's not really a major problem, I know, but I think that it is, at least in 
some
way, significant.

--
Charles Moss
Junior, Mathematics
Southwest Missouri State University
czm313s at smsu.edu





reply via email to

[Prev in Thread] Current Thread [Next in Thread]