Post Reply 
(42S) Quotient and Remainder
04-05-2023, 03:55 PM (This post was last modified: 04-05-2023 04:52 PM by Werner.)
Post: #5
RE: (42S) Quotient and Remainder
So, to work for negative X and/or Y, the algorithm should become:
(changes in red)

t := X/Y;
Q := FLOOR(t);
R := MOD(Y,X);
if t#Q then return(R,Q);
t := X - R;
if ABS(t)<ABS(R) then Q:= Q - 1;
if t=R then Q:= Q - MOD(FLOOR(MOD(Y,X*10)/X),2); /* equals IP(MOD(MOD(Y,X*10)/X,2)) */
return(R,Q);

Sigh. Back to the drawing board.[update: done]
Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(42S) Quotient and Remainder - Werner - 04-05-2023, 09:38 AM
RE: (42S) Quotient and Remainder - Werner - 04-05-2023, 01:11 PM
RE: (42S) Quotient and Remainder - Werner - 04-05-2023 03:55 PM



User(s) browsing this thread: 1 Guest(s)