,---------------. | Contributions | `---------------ยด ,------------------------------------------ | 2018-01-22 15:32:49 NieDzejkob wrote: | referenceImplementation - Implementing FM/MOD with SM/REM | see: https://forth-standard.org/standard/core/FMDivMOD#contribution-50 `------------------------------------------ ``` : FM/MOD ( d n -- rem quot ) DUP >R SM/REM ( if the remainder is not zero and has a different sign than the divisor ) OVER DUP 0<> SWAP 0< R@ 0< XOR AND IF 1- SWAP R> + SWAP ELSE RDROP THEN ; ```