X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fscheme-primitives.4th;h=5ec154b5812c2754ea88e944b753a2193aeb3b3e;hb=613b910f0ceb0ec0948a0e0595cd3e82086754cf;hp=8dad18e02a36959c667e3be3fa96a8785a6f7232;hpb=bc00d35dbd0f374bb568336dfd1dd40289288b96;p=scheme.forth.jl.git diff --git a/src/scheme-primitives.4th b/src/scheme-primitives.4th index 8dad18e..5ec154b 100644 --- a/src/scheme-primitives.4th +++ b/src/scheme-primitives.4th @@ -151,7 +151,7 @@ \ }}} -\ ==== Primitivle Arithmetic ==== {{{ +\ ==== Numeric types ==== {{{ \ --- Fixnums --- @@ -219,6 +219,11 @@ swap negate swap ; 1 make-fa-primitive fix:neg +:noname ( fixnum -- -fixnum ) + swap abs swap +; 1 make-fa-primitive fix:abs + + ( Find the GCD of n1 and n2 where n2 < n1. ) : gcd ( n1 n2 -- m ) @@ -279,6 +284,10 @@ ; 1 make-fa-primitive flo:finite? +:noname ( flonum -- flonum ) + swap -1.0 f* swap +; 1 make-fa-primitive flo:neg + :noname ( flonum -- flonum ) swap fabs swap ; 1 make-fa-primitive flo:abs @@ -359,6 +368,13 @@ drop swap drop f/ fatan flonum-type ; 2 make-fa-primitive flo:atan2 + +\ --- Conversion --- + +:noname ( fixnum -- flonum ) + drop i->f flonum-type +; 1 make-fa-primitive fixnum->flonum + \ }}} \ ==== Pairs and Lists ==== {{{