Subject: bug#66696: 29.1; "A bug in the function debug."

From: Gerd Möllmann <[email-masked]>
Date: Mon, 23 Oct 2023 21:11:55 +0200

Lewis Creary <[email-masked]> writes:

(Please reply to all, so that your mails get to the bug tracker.)

>>> Did you get your parentheses right? The above ')' is the end of the while.
>
> I checked, and the extra parenthesis is in my bug report, but not in the code I tried to run.  I'd be interested to know if you can reproduce my
> problem in emacs lisp, with correct parentheses.
>
>    --  Lew Creary

1:    (while ((and (>= dividend 0) (not stop-sw)))
2:       (setq dividend (/ dividend 2)
3:             rmdr-list (append (list (% dividend 2)) rmdr-list) )

You write in the bug report that you start with dividend being 5, and
you expect the first element of the list to be 1, but it is 0.

When you look at line 2, dividend is divided by 2, which results in 5 /
2 = 2, because this is integer division.  In line 3, you compute the rest
of dividend (which is now 2) when divided by 2, which results in 0.

So, this looks correct.