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

Bug#751153: Can't start number with dot immediately after certain ops



Package: x11-apps
Version: 7.7~2
Severity: minor
Tags: patch

When pressing the dot after certain operations, xcalc misbehaves in
several respects.

For example, to find the log of .1 and .01:

Start xcalc. "0" is displayed.
Press ".". "0." is displayed.
Press "1". "0.1" is displayed.
Press "log". "-1" is displayed. So far so good.
Press ".". Nothing seems to happen; "-1" keeps being displayed.
I expected the display to change to "0.". But things get a bit worse
from this point on:
Press "0". "00" is displayed. I expected "0.0" to be displayed, or if
the dot was not accepted, just "0".
Press ".". Nothing happens. "00" keeps being displayed.
In the hope that the dot is there but invisible, press "1". "001" is
displayed.
Press "log". "0" is the result, which is the log of 1, not of 0.01.

The same happens with many other operations and constants: sin, cos,
tan, pi, e, etc.; if the last number typed had a dot, and you press the
dot immediately after any of these, the dot doesn't appear, any zeros
are typed rather than eaten, and if you press another dot, it doesn't
appear.

This happens both in normal and RPN mode.

A similar effect happens with the EE key, although that's less important
because you don't want a zero mantissa anyway, so you don't usually
press EE to start a number.

If the last operation was "=" or ")" (in non-RPN mode) or "*", "+", etc.
(in RPN mode), this problem doesn't happen. Typing a "." after them
always clears the display and shows "0." as expected.

The attached patch fixes it for me. I'm not completely sure if it may
introduce other problems, though.
--- xcalc/math.c~	2012-06-07 11:38:25.000000000 +0200
+++ xcalc/math.c	2014-06-10 21:18:53.000000000 +0200
@@ -710,6 +710,8 @@ oneop(int keynum)
   int i,j;
   double dtmp;
 
+  Dpoint=exponent=0;
+
   if (entered==1)
     parse_double(dispstr,"%lf",&dnum);
   entered = 2;

Reply to: