GNU bug report logs - #37235
26.1; Precedence error in calc-eval

Previous Next

Package: emacs;

Reported by: Charles Karney <charles <at> karney.com>

Date: Fri, 30 Aug 2019 14:44:02 UTC

Severity: normal

Tags: notabug

Found in version 26.1

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 37235 in the body.
You can then email your comments to 37235 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#37235; Package emacs. (Fri, 30 Aug 2019 14:44:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Charles Karney <charles <at> karney.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 30 Aug 2019 14:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Charles Karney <charles.karney <at> sri.com>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 26.1; Precedence error in calc-eval
Date: Fri, 30 Aug 2019 13:41:32 +0000
In GNU Emacs 26.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.23.2)
  of 2018-08-13 built on buildvm-13.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.12004000
System Description:	Fedora release 29 (Twenty Nine)

The precedence of calc-eval doesn't follow C-like rules.

   (calc-eval "1/2*3") returns "0.166666666667"

returning the same answer as (calc-eval "1/2/3").  It should return
"1.5".

Configured using:
  'configure --build=x86_64-redhat-linux-gnu
  --host=x86_64-redhat-linux-gnu --program-prefix=
  --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
  --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
  --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
  --libexecdir=/usr/libexec --localstatedir=/var
  --sharedstatedir=/var/lib --mandir=/usr/share/man
  --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
  --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
  --with-gpm=no --with-xwidgets --with-modules
  build_alias=x86_64-redhat-linux-gnu host_alias=x86_64-redhat-linux-gnu
  'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Werror=format-security
  -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
  -fstack-protector-strong -grecord-gcc-switches
  -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
  -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
  -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
  LDFLAGS=-Wl,-z,relro
  PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY ACL
LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS XWIDGETS LCMS2

Important settings:
   value of $LC_COLLATE: C
   value of $LC_TIME: C
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=none
   locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
   diff-auto-refine-mode: t
   save-place-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-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
   line-number-mode: t
   transient-mark-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/site-start.d/maxima-modes hides 
/usr/share/emacs/site-lisp/maxima/site_start.d/maxima-modes

Features:
(shadow sort emacsbug help-mode cl-print debug calc-alg ispell maxima
maxima-font-lock rect misearch multi-isearch calc-map calc-stat calc-vec
calc-ext calc-menu calc-aent calc calc-loaddefs calc-macs org-table
org-rmail org-mhe org-irc org-info org-gnus nnir 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 gnus-win gnus
nnheader wid-edit org-docview doc-view jka-compr image-mode org-bibtex
bibtex org-bbdb org-w3m org-element avl-tree generator org advice
org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline org-version ob-emacs-lisp ob ob-tangle
org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint comint
ansi-color ring ob-core ob-eval org-compat org-macs org-loaddefs
find-func cal-menu calendar cal-loaddefs vc-git diff-mode easy-mmode
cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine
cc-vars cc-defs mail-extr message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec epa derived epg epg-config
gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse
rfc2231 mailabbrev gmm-utils mailheader warnings lpr elec-pair saveplace
edmacro kmacro tempo url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-domsuf url-util url-parse url-vars mailcap
xml-parse doxymacs matlab-load cmake-mode thingatpt rx smtpmail
auth-source cl-seq eieio eieio-core eieio-loaddefs password-cache
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
50magit clang-rename clang-include-fixer let-alist json map seq byte-opt
bytecomp byte-compile cconv clang-format cl-macs gv xml cl-loaddefs
cl-lib time-date mule-util tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors 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 composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray 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 lcms2
dynamic-setting system-font-setting font-render-setting xwidget-internal
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 295915 64123)
  (symbols 48 39027 3)
  (miscs 40 315 855)
  (strings 32 88008 6139)
  (string-bytes 1 2737911)
  (vectors 16 42045)
  (vector-slots 8 1462820 203824)
  (floats 8 223 624)
  (intervals 56 3321 604)
  (buffers 992 34))

-- 
Charles Karney <charles <at> karney.com>
Princeton, NJ 08540, USA
https://www.petrel.org

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37235; Package emacs. (Fri, 30 Aug 2019 15:05:02 GMT) Full text and rfc822 format available.

Message #8 received at 37235 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Charles Karney <charles.karney <at> sri.com>
Cc: 37235 <at> debbugs.gnu.org
Subject: Re: bug#37235: 26.1; Precedence error in calc-eval
Date: Fri, 30 Aug 2019 12:04:35 -0300
[Message part 1 (text/plain, inline)]
tags 37235 notabug
quit

Charles Karney via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

> In GNU Emacs 26.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.23.2)
>   of 2018-08-13 built on buildvm-13.phx2.fedoraproject.org
> Windowing system distributor 'Fedora Project', version 11.0.12004000
> System Description: Fedora release 29 (Twenty Nine)
>
> The precedence of calc-eval doesn't follow C-like rules.
>
>    (calc-eval "1/2*3") returns "0.166666666667"
>
> returning the same answer as (calc-eval "1/2/3").  It should return
> "1.5".
>

It works as documented in the Calc manual, section 5.15 Formulas:
C-h i m calc RET 5 m formulas RET

Calc gives '/' lower precedence than '*' by default.

To make Calc follow C-like rules, you can set it with the command
calc-c-language.  You can read its documentation with:
C-h i m calc RET i calc-c-language


Best regards,
Mauro.
[Message part 2 (text/html, inline)]

Added tag(s) notabug. Request was from Mauro Aranda <maurooaranda <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 30 Aug 2019 15:05:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37235; Package emacs. (Fri, 30 Aug 2019 15:08:01 GMT) Full text and rfc822 format available.

Message #13 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Charles Karney via "Bug reports for GNU Emacs\,
 the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
Cc: 37235 <at> debbugs.gnu.org, Charles Karney <charles.karney <at> sri.com>
Subject: Re: bug#37235: 26.1; Precedence error in calc-eval
Date: Fri, 30 Aug 2019 17:07:08 +0200
On Aug 30 2019, Charles Karney via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org> wrote:

> The precedence of calc-eval doesn't follow C-like rules.
>
>    (calc-eval "1/2*3") returns "0.166666666667"
>
> returning the same answer as (calc-eval "1/2/3").  It should return
> "1.5".

It is documented that multiplication has higher precedence than
devision (see (calc) Formulas).  Calc is following the rules of
Algebra.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37235; Package emacs. (Fri, 30 Aug 2019 15:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#37235; Package emacs. (Fri, 30 Aug 2019 15:28:02 GMT) Full text and rfc822 format available.

Message #19 received at 37235 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: Charles Karney <charles.karney <at> sri.com>, 37235 <at> debbugs.gnu.org
Subject: Re: bug#37235: 26.1; Precedence error in calc-eval
Date: Fri, 30 Aug 2019 11:26:57 -0400
Mauro Aranda <maurooaranda <at> gmail.com> writes:
>>
>> The precedence of calc-eval doesn't follow C-like rules.
>>
>>    (calc-eval "1/2*3") returns "0.166666666667"
>>
>> returning the same answer as (calc-eval "1/2/3").  It should return
>> "1.5".
>>
>
> It works as documented in the Calc manual, section 5.15 Formulas:
> C-h i m calc RET 5 m formulas RET
>
> Calc gives '/' lower precedence than '*' by default.

Also see (info "(calc) Basic Arithmetic"),

> To make Calc follow C-like rules, you can set it with the command
> calc-c-language.  You can read its documentation with:
> C-h i m calc RET i calc-c-language

which mentions calc-multiplication-has-precedence.





Reply sent to Stefan Kangas <stefan <at> marxist.se>:
You have taken responsibility. (Mon, 16 Sep 2019 03:07:02 GMT) Full text and rfc822 format available.

Notification sent to Charles Karney <charles <at> karney.com>:
bug acknowledged by developer. (Mon, 16 Sep 2019 03:07:02 GMT) Full text and rfc822 format available.

Message #24 received at 37235-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: Charles Karney <charles.karney <at> sri.com>, 37235-done <at> debbugs.gnu.org
Subject: Re: bug#37235: 26.1; Precedence error in calc-eval
Date: Mon, 16 Sep 2019 05:06:07 +0200
Mauro Aranda <maurooaranda <at> gmail.com> writes:
>
> tags 37235 notabug
> quit
>
> Charles Karney via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs <at> gnu.org> writes:
>
> > In GNU Emacs 26.1 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.23.2)
> >   of 2018-08-13 built on buildvm-13.phx2.fedoraproject.org
> > Windowing system distributor 'Fedora Project', version 11.0.12004000
> > System Description: Fedora release 29 (Twenty Nine)
> >
> > The precedence of calc-eval doesn't follow C-like rules.
> >
> >    (calc-eval "1/2*3") returns "0.166666666667"
> >
> > returning the same answer as (calc-eval "1/2/3").  It should return
> > "1.5".
> >
>
> It works as documented in the Calc manual, section 5.15 Formulas:
> C-h i m calc RET 5 m formulas RET
>
> Calc gives '/' lower precedence than '*' by default.
>
> To make Calc follow C-like rules, you can set it with the command
> calc-c-language.  You can read its documentation with:
> C-h i m calc RET i calc-c-language

Since this is notabug, I'm also closing it.

Best regards,
Stefan Kangas




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 14 Oct 2019 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 188 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.