unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs Calc Bug: calc-cplx.el:math-imaginary-i
       [not found] ` <20180809223951.GA26689@belanger-home>
@ 2018-08-10 10:51   ` Erdnüß, Bastian (IPF)
  2018-08-15  3:24     ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Erdnüß, Bastian (IPF) @ 2018-08-10 10:51 UTC (permalink / raw)
  To: emacs-devel@gnu.org

During code review I think I spotted a bug in the function
math-imaginary-i at calc-cplx.el:271.

Line 276 reads "(eq (nth 1 val) 0)" but I think it should read
"(eq (nth 0 val) 1)", i.e. the length of the complex number in
polar form should be one, instead of that the angle to the real
axis should be zero.  The angle to the real axis will be taken
care of in the following line.

Comment from Jay Belanger:

> If that's in an "if polar coordinates" check, then that's a very
> unfortunate bug; thanks for catching that.  I don't work on Emacs any
> more, but you should write to emacs-devel@gnu.org and mention it.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Emacs Calc Bug: calc-cplx.el:math-imaginary-i
  2018-08-10 10:51   ` Emacs Calc Bug: calc-cplx.el:math-imaginary-i Erdnüß, Bastian (IPF)
@ 2018-08-15  3:24     ` Noam Postavsky
  2018-08-28 12:15       ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2018-08-15  3:24 UTC (permalink / raw)
  To: Erdnüß, Bastian (IPF); +Cc: emacs-devel@gnu.org

On 10 August 2018 at 06:51, Erdnüß, Bastian (IPF)
<bastian.erdnuess@kit.edu> wrote:
> During code review I think I spotted a bug in the function
> math-imaginary-i at calc-cplx.el:271.
>
> Line 276 reads "(eq (nth 1 val) 0)" but I think it should read
> "(eq (nth 0 val) 1)", i.e. the length of the complex number in
> polar form should be one, instead of that the angle to the real
> axis should be zero.  The angle to the real axis will be taken
> care of in the following line.

(nth 0 val) would be the symbol `polar', so I think (eq (nth 1 val) 1)
is what was intended. And the Math-equal on the next line should be
checking (nth 2 val).

(defun math-imaginary-i ()
  (let ((val (calc-var-value 'var-i)))
    (or (eq (car-safe val) 'special-const)
    (equal val '(cplx 0 1))
    (and (eq (car-safe val) 'polar)
         (eq (nth 1 val) 0) ;;;;;;; line 276
         (Math-equal (nth 1 val) (math-quarter-circle nil))))))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Emacs Calc Bug: calc-cplx.el:math-imaginary-i
  2018-08-15  3:24     ` Noam Postavsky
@ 2018-08-28 12:15       ` Noam Postavsky
  0 siblings, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2018-08-28 12:15 UTC (permalink / raw)
  To: Erdnüß, Bastian (IPF); +Cc: emacs-devel@gnu.org

On 14 August 2018 at 23:24, Noam Postavsky <npostavs@gmail.com> wrote:

> (nth 0 val) would be the symbol `polar', so I think (eq (nth 1 val) 1)
> is what was intended. And the Math-equal on the next line should be
> checking (nth 2 val).

Done in emacs-26.

[1: f088817923]: 2018-08-28 08:04:17 -0400
  Fix math-imaginary-i check
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=f0888179237b25e32b46a8a855acb3d3453e4c69



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-28 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <5609bcdab92948b082877be552ce52c5@kit-msx-24.kit.edu>
     [not found] ` <20180809223951.GA26689@belanger-home>
2018-08-10 10:51   ` Emacs Calc Bug: calc-cplx.el:math-imaginary-i Erdnüß, Bastian (IPF)
2018-08-15  3:24     ` Noam Postavsky
2018-08-28 12:15       ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).