GNU bug report logs -
#75861
31.0.50; calc units error
Previous Next
Reported by: çağlar girit <cog <at> pelagi.cc>
Date: Sun, 26 Jan 2025 13:15:02 UTC
Severity: normal
Found in version 31.0.50
Fixed in version 31.1
Done: Ulrich Müller <ulm <at> gentoo.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
I can reproduce the bug as follows:
emacs -Q ;; without .emacs.d/calc.el file
M-x calc
d M ;; calc-mathematica-language
' 10 cm ;; algebraic entry
u s ;; calc-simplify-units
Error "Unknown name ln in defining expression for unit dB"
In other calc language modes, it seems to work fine although I
didn't test exhaustively.
The error arises because in calc-mathematica-language, algebraic
entry of "ln(10)" doesn't yield the numerical value
2.30258509299, but rather "10 ln" which means 10 times some
variable "ln".
The expression "ln(10)" is hardcoded in the units table in
calc-units.el. When calc-simplify-units executes, it builds the
units table and attempts to evaluate "ln(10)" (line 317) when
deriving the SI equivalent of a dB. Since "ln(10)" is incorrectly
evaluated in mathematica language mode, there is an error.
So perhaps there is a bug somewhere in the Mathematica language
implementation, starting at calc-lang.el line 1816, but difficult
for me to find.
On 2025-01-27 at 18:37:53, Eli Zaretskii wrote:
>> Cc: 75861 <at> debbugs.gnu.org
>> Date: Mon, 27 Jan 2025 17:18:20 +0100
>> From: çağlar girit via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>>
>> You were right! The line causing the problem was
>>
>> (setq calc-language 'math)
>>
>> Which put calc in Mathematica mode and changed how it
>> interpreted
>> math expressions with functions, such as "ln" or "sin".
>
> Thanks for telling us.
>
> Is Calc supposed to signal an error when you type "' 10 cm" in
> Mathematica mode, or is that still some (other) kind of bug?
>
>> I don't know how this line appeared in my .emacs.d/calc.el.
>>
>> calc's definition of the dB unit includes "ln(10)", and calc
>> builds the units table before evaluating certain algebraic
>> expressions. This resulted in the original error message I
>> submitted.
>>
>> My apologies.
>
> No need to apologize, anyone could make a mistake.
--
çög
This bug report was last modified 102 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.