GNU bug report logs -
#19582
25.0.50; [PATCH] Calc: glitches with negation of units
Previous Next
Reported by: Wolfgang Jenkner <wjenkner <at> inode.at>
Date: Tue, 13 Jan 2015 14:31:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 25.0.50
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Start Calc (M-x calc).
Try to convert -1m to cm. Type
'-1m<return>uc
Then Calc asks
`(The expression is unitless when simplified) Old Units:'
This is the first glitch here, but, regardless, answer the question
m<return>
Now, it asks (correctly) for new units, so type
cm<return>
This gives the surprising result `-100 m' on top of the stack.
Now, if you do the same thing with -2 instead of -1, everything works fine.
The reason is that some of the functions in calc-units.el which, in
various ways, test for the presence of units in a given (simplified)
expression forget to handle subexpressions of the form (neg <expr>).
I propose the attached patch, which also contains some modest additions
to test/automated/cl-lib-tests.el.
There's also some math-defsimplify stuff in calc-units.el which fails to
handle the neg operator, but that shouldn't give rise to mathematical
errors and will be done in another patch.
This patch is also needed for (and, in fact, was prompted by) bug#19401.
[0001-Handle-the-neg-operator-in-some-calc-units-functions.patch (text/x-diff, attachment)]
This bug report was last modified 9 years and 86 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.