shithub: femtolisp

Download patch

ref: 1ee781cb64e6fa05bf9b60a0065d4839da546f52
parent: 74761f99b3ab80b2df581c1c141d28f9681f6c3d
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Wed Nov 13 01:55:11 EST 2024

add floor and ceiling

--- a/aliases.scm
+++ b/aliases.scm
@@ -55,8 +55,6 @@
   (if (integer-valued? x)
       (truncate x)
       (error "exact real numbers not supported")))
-(define (floor x)   (if (< x 0) (truncate (- x 0.5)) (truncate x)))
-(define (ceiling x) (if (< x 0) (truncate x) (truncate (+ x 0.5))))
 (define (finite? x) (and (< x +inf.0) (> x -inf.0)))
 (define (infinite? x) (or (equal? x +inf.0) (equal? x -inf.0)))
 
@@ -284,3 +282,4 @@
 
 (define (read-u8) (io-read *input-stream* 'uint8))
 (define modulo mod)
+#t
--- a/builtins.c
+++ b/builtins.c
@@ -445,6 +445,8 @@
 BUILTIN_("asin", asin)
 BUILTIN_("acos", acos)
 BUILTIN_("atan", atan)
+BUILTIN_("floor", floor)
+BUILTIN_("ceiling", ceil)
 
 #undef BUILTIN_
 #define BUILTIN_(lname, cname) \