1 \ @(#) math.fth 98/01/26 1.2
2 \ Extended Math routines
6 \ Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
8 \ The pForth software code is dedicated to the public domain,
9 \ and any third party may reproduce, distribute and modify
10 \ the pForth software code or any derivative works thereof
11 \ without any compensation or license. The pForth software
12 \ code is provided on an "as is" basis without any warranty
13 \ of any kind, including, without limitation, the implied
14 \ warranties of merchantability and fitness for a particular
15 \ purpose and their equivalents under the laws of any jurisdiction.
20 : FM/MOD { dl dh nn | dlp dhp nnp rem quo -- rem quo , floored }
21 dl dh dabs -> dhp -> dlp
23 dlp dhp nnp um/mod -> quo -> rem
25 IF \ negative dividend
29 ELSE \ positive divisor
38 ELSE \ positive dividend
45 nnp rem - negate -> rem
53 : SM/REM { dl dh nn | dlp dhp nnp rem quo -- rem quo , symmetric }
54 dl dh dabs -> dhp -> dlp
56 dlp dhp nnp um/mod -> quo -> rem
58 IF \ negative dividend
64 ELSE \ positive dividend
74 : /MOD ( a b -- rem quo )
82 : */MOD ( a b c -- rem a*b/c , use double precision intermediate value )
86 : */ ( a b c -- a*b/c , use double precision intermediate value )