You nearly always get the remainder as a side effect if you implement a division algorithm using long (binary) division (you don't with a lookup though of course).sn3j wrote: ↑Wed Apr 03, 2024 10:41 pm There's something similar used on Z80 heaven.
The algorithms look quite similar to the division routines, the fastest afaik was some unrolled loop with 330T for a 16 bit integer root with remainder(?).
Problem is that anything that requires multiplication or division isn't going to work on a Z80.
Which is why many modern PC C/C++ compilers have an intrinsic divmod instruction which returns both. (Also sincos which gets sine and cosine in 1 call too). Optimisers these days are clever and if you use a division and also want the remainder they know about it and will use the single instruction anyway.