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

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

bug#19582: 25.0.50; [PATCH] Calc: glitches with negation of units


From: Wolfgang Jenkner
Subject: bug#19582: 25.0.50; [PATCH] Calc: glitches with negation of units
Date: Tue, 13 Jan 2015 15:22:28 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (berkeley-unix)

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.

Attachment: 0001-Handle-the-neg-operator-in-some-calc-units-functions.patch
Description: neg operator glitches


reply via email to

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