GNU bug report logs -
#23889
25.0.95; Calc; calc-simplify-units not working as documented for trigometric functions
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23889 in the body.
You can then email your comments to 23889 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23889
; Package
emacs
.
(Sun, 03 Jul 2016 17:06:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
dieter <at> duenenhof-wilhelm.de (H. Dieter Wilhelm)
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 03 Jul 2016 17:06:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
In Calc do
'sin(45 deg)
u s
Result: 0.0137073546047
Expected result: 0.707106781187
The actual result equals to sin(pi/4) in deg mode whereas the expected
result of "the sine of 45 degrees" is the one documented in
(info "(calc) Trigonometric and Hyperbolic Functions").
The same applies for other trigonometric functions and for other values
of 45 or the 'deg' unit (i.e. 'rad or 'grad').
This was originally a bug report from David Ongaro in
http://lists.gnu.org/archive/html/emacs-devel/2016-07/msg00050.html
Thanks
Dieter
In GNU Emacs 25.0.95.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.14.5)
of 2016-06-19 built on urmel
Windowing system distributor 'The X.Org Foundation', version 11.0.11604000
System Description: Debian GNU/Linux 8.5 (jessie)
Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11
Important settings:
value of $LANG: en_GB.utf8
locale-coding-system: utf-8-unix
Major mode: Info
Minor modes in effect:
show-paren-mode: t
electric-pair-mode: t
icomplete-mode: t
global-hl-line-mode: t
shell-dirtrack-mode: t
display-time-mode: t
auto-insert-mode: t
server-mode: t
minibuffer-depth-indicate-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent messages:
Mark set [12 times]
Mark activated
Mark set
Auto-saving...done
Contacting host: lists.gnu.org:80
Mark set [2 times]
Mark saved where search started
Mark set [2 times]
Mark saved where search started
mwheel-scroll: Beginning of buffer
Load-path shadows:
None found.
Features:
(shadow emacsbug shr-color color pp flow-fill eww url-queue qp shr dom
debug calc-undo calc-help pulse xref project eieio-opt calc-units
calc-math calc-arith calc-misc calccomp calc-aent calc-alg calc-menu
nndoc debbugs-gnu add-log debbugs soap-client warnings rng-xsd rng-dt
rng-util xsd-regexp canlock misearch multi-isearch bbdb-message
mailalias sendmail flyspell ispell nnir sort smiley gnus-cite mail-extr
gnus-async gnus-bcklg gnus-kill gnus-dup gnus-ml disp-table gnus-topic
mm-archive url-http url-gw url-cache url-auth url-handlers nnrss xml
mm-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie url-domsuf url-util nndraft nnmh utf-7 nnmbox nnfolder
time-stamp bbdb-gnus bbdb-mua epa-file epa derived network-stream nsm
starttls gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-msg
gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap nntp
gnus-cache gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap
nnmail mail-source tls gnutls utf7 netrc nnoo parse-time gnus-spec
gnus-int gnus-range message rfc822 mml mml-sec epg mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums gmm-utils
mailheader gnus-win gnus gnus-ems nnheader mail-utils wid-edit ffap
url-parse url-vars paren elec-pair icomplete hl-line dired-x ob-maxima
ob-latex ob-sh ob-calc calc-store calc-trail calc-ext ob-R ob-python
ox-koma-letter ox-beamer ox-rss ox-taskjuggler ox-latex ox-icalendar
ox-html ox-ascii ox-publish ox ido ess-toolbar ess-mouse mouseme
thingatpt browse-url ess-menu ess-swv ess-noweb ess-noweb-font-lock-mode
ess-bugs-l essd-els ess-sas-d ess-sas-l ess-sas-a ess-sta-d ess-sta-l
cc-vars cc-defs make-regexp ess-sp6-d ess-sp3-d ess-julia ess-r-d
ess-tracebug compile tramp tramp-compat tramp-loaddefs trampver
ucs-normalize shell ess-roxy advice hideshow ess-help reporter
ess-developer ess-r-args ess-s-l speedbar sb-image ezimage dframe ess
ess-inf ess-mode ess-noweb-mode edmacro kmacro ess-utils cl ess-custom
executable ess-compat ess-site org-mobile org-agenda calc calc-loaddefs
calc-macs auth-source cl-seq eieio eieio-core cl-macs mm-util help-fns
mail-prsvr password-cache view cal-china lunar solar cal-dst cal-bahai
cal-islam cal-hebrew holidays hol-loaddefs appt diary-lib diary-loaddefs
battery time bbdb-print bbdb-com crm mailabbrev bbdb bbdb-site timezone
bbdb-loaddefs org-element org-rmail org-mhe org-irc org-info org-gnus
gnus-util org-docview doc-view subr-x jka-compr image-mode dired
org-bibtex bibtex org-bbdb org-w3m org org-macro org-footnote
org-pcomplete pcomplete org-list org-faces org-entities noutline outline
easy-mmode org-version ob-emacs-lisp ob ob-tangle ob-ref ob-lob ob-table
ob-exp org-src ob-keys ob-comint comint ansi-color ring ob-core ob-eval
org-compat org-macs org-loaddefs format-spec find-func cal-menu calendar
cal-loaddefs autoinsert server mb-depth finder-inf info package
epg-config seq byte-opt gv bytecomp byte-compile cl-extra help-mode
easymenu cconv cl-loaddefs pcase cl-lib time-date mule-util tooltip
eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help
simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
dbusbind inotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)
Memory information:
((conses 16 821555 68008)
(symbols 48 62134 0)
(miscs 40 8505 2890)
(strings 32 156791 19382)
(string-bytes 1 4740983)
(vectors 16 70983)
(vector-slots 8 1215228 38104)
(floats 8 1492 549)
(intervals 56 11764 1170)
(buffers 976 55)
(heap 1024 98278 29923))
--
Best wishes
H. Dieter Wilhelm
Kelkheim, Germany
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#23889
; Package
emacs
.
(Mon, 04 Jul 2016 08:20:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 23889 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for the report.
From the documentation:
"(‘calc-simplify-units’) command will simplify ‘sin(45 deg)’ by taking
the sine of 45 degrees, regardless of the current angular mode."
The problem is that ‘calc-simplify-units’ is actually checking the value
of 'calc-angle-mode'.
There is an internal variable 'math-simplifying-units';
'match-simplify-units' bind this var to a non-nil value
while performing its task.
Following patch use 'math-simplifying-units' to prevent that
'calc-simplify-units' use the value of 'calc-angle-mode'.
Regards,
Tino
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 96b92d9793bd035a4f0ed79a4e434418b0253608 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha <at> gmail.com>
Date: Mon, 4 Jul 2016 16:32:27 +0900
Subject: [PATCH] Ignore angle mode when simplifying units
* lisp/calc/calc-forms.el (math-to-hms, math-from-hms):
Ignore value of 'calc-angle-mode' when 'math-simplifying-units'
evaluates non-nil (Bug#23889).
* lisp/calc/calc-math.el (math-to-radians)
(math-from-radians-2, math-to-radians-2): Idem.
---
lisp/calc/calc-forms.el | 12 +++++++++---
lisp/calc/calc-math.el | 9 +++++----
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/lisp/calc/calc-forms.el b/lisp/calc/calc-forms.el
index c94b89d..153b904 100644
--- a/lisp/calc/calc-forms.el
+++ b/lisp/calc/calc-forms.el
@@ -317,7 +317,9 @@ math-to-hms
(list 'calcFunc-hms a))
((math-negp a)
(math-neg (math-to-hms (math-neg a) ang)))
- ((eq (or ang calc-angle-mode) 'rad)
+ ((eq (or ang
+ (and (not math-simplifying-units) calc-angle-mode))
+ 'rad)
(math-to-hms (math-div a (math-pi-over-180)) 'deg))
((memq (car-safe a) '(cplx polar)) a)
(t
@@ -354,12 +356,16 @@ math-from-hms
(if (eq (car-safe a) 'sdev)
(math-make-sdev (math-from-hms (nth 1 a) ang)
(math-from-hms (nth 2 a) ang))
- (if (eq (or ang calc-angle-mode) 'rad)
+ (if (eq (or ang
+ (and (not math-simplifying-units)
calc-angle-mode))
+ 'rad)
(list 'calcFunc-rad a)
(list 'calcFunc-deg a)))))
((math-negp a)
(math-neg (math-from-hms (math-neg a) ang)))
- ((eq (or ang calc-angle-mode) 'rad)
+ ((eq (or ang
+ (and (not math-simplifying-units) calc-angle-mode))
+ 'rad)
(math-mul (math-from-hms a 'deg) (math-pi-over-180)))
(t
(math-add (math-div (math-add (math-div (nth 3 a)
diff --git a/lisp/calc/calc-math.el b/lisp/calc/calc-math.el
index 699ef6f..d35460e 100644
--- a/lisp/calc/calc-math.el
+++ b/lisp/calc/calc-math.el
@@ -763,12 +763,13 @@ calcFunc-nroot
(defun math-to-radians (a) ; [N N]
(cond ((eq (car-safe a) 'hms)
(math-from-hms a 'rad))
- ((memq calc-angle-mode '(deg hms))
+ ((and (not math-simplifying-units)
+ (memq calc-angle-mode '(deg hms)))
(math-mul a (math-pi-over-180)))
(t a)))
(defun math-from-radians (a) ; [N N]
- (cond ((eq calc-angle-mode 'deg)
+ (cond ((and (not math-simplifying-units) (eq calc-angle-mode 'deg))
(if (math-constp a)
(math-div a (math-pi-over-180))
(list 'calcFunc-deg a)))
@@ -779,14 +780,14 @@ math-from-radians
(defun math-to-radians-2 (a &optional force-symbolic) ; [N N]
(cond ((eq (car-safe a) 'hms)
(math-from-hms a 'rad))
- ((memq calc-angle-mode '(deg hms))
+ ((and (not math-simplifying-units) (memq calc-angle-mode '(deg
hms)))
(if (or calc-symbolic-mode force-symbolic)
(math-div (math-mul a '(var pi var-pi)) 180)
(math-mul a (math-pi-over-180))))
(t a)))
(defun math-from-radians-2 (a &optional force-symbolic) ; [N N]
- (cond ((memq calc-angle-mode '(deg hms))
+ (cond ((and (not math-simplifying-units) (memq calc-angle-mode '(deg
hms)))
(if (or calc-symbolic-mode force-symbolic)
(math-div (math-mul 180 a) '(var pi var-pi))
(math-div a (math-pi-over-180))))
--
2.8.1
In GNU Emacs 25.1.50.5 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6)
of 2016-07-04
Repository revision: 05d76dba6604f78e4b2b7b9f8b30c916cad7d32a
Reply sent
to
Tino Calancha <tino.calancha <at> gmail.com>
:
You have taken responsibility.
(Mon, 11 Jul 2016 15:42:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
dieter <at> duenenhof-wilhelm.de (H. Dieter Wilhelm)
:
bug acknowledged by developer.
(Mon, 11 Jul 2016 15:42:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 23889-done <at> debbugs.gnu.org (full text, mbox):
Fixed in master branch
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 09 Aug 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 137 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.