diff --git a/README.md b/README.md index 1bddad76..eab4e402 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ | 6.2.3 Implementation restrictions | yes | | | 6.2.4 Implementation extensions | yes | | | 6.2.5 Syntax of numerical constants | yes | | -| 6.2.6 Numerical operations | yes | some functions that return multiple values are not supported for now. Also, picrin does not provide complex library procedures. | +| 6.2.6 Numerical operations | yes | `denominator`, `numerator`, and `rationalize` are not supported for now. Also, picrin does not provide complex library procedures. | | 6.2.7 Numerical input and output | no | | | 6.3 Booleans | yes | | | 6.4 Pairs and lists | yes | | diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 9eb4d8a4..f964edcf 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -272,6 +272,20 @@ (car (cddr x)))) bindings)))))) +;;; 6.2. Numbers + +(define (floor/ n m) + (values (floor-quotient n m) + (floor-remainder n m))) + +(define (truncate/ n m) + (values (truncate-quotient n m) + (truncate-remainder n m))) + +(define (exact-integer-sqrt k) + (let ((n (exact (sqrt k)))) + (values n (- k (square n))))) + (define (boolean=? . objs) (define (every pred list) (if (null? list)