31 lines
859 B
Forth
Executable File
31 lines
859 B
Forth
Executable File
\ double-arith.fs - Double-precision arithmetic extensions
|
|
|
|
\ Copyright 2013 David Meyer <papa@sdf.org> +JMJ
|
|
|
|
\ Copying and distribution of this file, with or without
|
|
\ modification, are permitted in any medium without royalty
|
|
\ provided the copyright notice and this notice are preserved.
|
|
\ This file is offered as-is, without any warranty.
|
|
|
|
\ MAXU - Maximum value of unsigned single
|
|
s" MAX-U" environment? drop constant MAXU
|
|
|
|
\ md* - Multiply double by unsigned single (iterative method)
|
|
: md* ( d u -- d*u )
|
|
0. rot
|
|
0 u+do 2over d+ loop
|
|
2nip
|
|
;
|
|
|
|
\ mudu* - Multiply unsigned double by unsigned single
|
|
: mudu* ( ud u -- ud*u ) tuck * >r m* r> + ;
|
|
|
|
\ ud* - Multiply two unsigned doubles
|
|
: ud* ( ud1 ud2 -- ud1*ud2 )
|
|
{ a1 b1 a2 b2 }
|
|
a1 a2 um*
|
|
MAXU a1 um* b2 mudu* d+
|
|
MAXU a2 um* b1 mudu* d+
|
|
MAXU MAXU um* b1 mudu* b2 mudu* d+
|
|
;
|