jax@well.UUCP (Jack J. Woehr) (07/21/89)
W.BADEN1 [Wil] at 23:03 PDT Quotients & Remainders I am looking for uncontrived examples from existing applications where (1) floored division, or (2) the remainder after division by a negative number, are important. This is the second time of asking. I have found an example of floored division in something I had already written. The following definition displays the value on top of the stack. It is like "." except there is no sign, no space, and the value at BASE may be negative. "digit" converts a digit to a character. : .recursively ( n -- ) BASE @ ABS /MOD ( r q) ?DUP IF BASE @ 0< IF NEGATE THEN RECURSE ( r) THEN digit EMIT ; "." can now be defined : . ( n -- ) DUP 0< BASE @ 0> AND IF ." -" NEGATE THEN .recursively ( ) SPACE ; Like all other candidates for examples of floored division, phrases "OVER 0< +" and "DUP 0< Divisor AND +" make Floored versus Truncated remainder and quotient immaterial. : .recursively ( n -- ) BASE @ ABS /MOD ( r q) ?DUP IF BASE @ 0< IF OVER 0< + NEGATE THEN RECURSE ( r) THEN DUP 0< BASE @ ABS AND + digit EMIT ; I still have not found anything for the remainder after division by a negative number. --Wil. __________________________________________________________________________ Please reply directly to ANSI X3J14 TC or by posting in this topic or by email to poster. All replies forwarded to the TC member requesting the feedback ( Wil Baden ). Thank you. {}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{} {} {} {} jax@well ." Sysop, Realtime Control and Forth Board" FIG {} {} jax@chariot ." (303) 278-0364 3/12/2400 8-n-1 24 hrs." Chapter {} {} JAX on GEnie ." Tell them JAX sent you!" Coordinator {} {} {} {} "Darkness is so great it can give horns to a dog." -Chinua Achebe {} {} {} {}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}