mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-04 03:36:36 +02:00
inserting commas in numerator and denominator separately for rationals
This commit is contained in:
parent
4c5bdcb22c
commit
7380564933
1 changed files with 10 additions and 10 deletions
|
@ -254,10 +254,6 @@
|
||||||
(cond
|
(cond
|
||||||
(precision
|
(precision
|
||||||
(gen-fixed n))
|
(gen-fixed n))
|
||||||
((and (exact? n) (not (integer? n)))
|
|
||||||
(string-append (gen-positive-real (numerator n))
|
|
||||||
"/"
|
|
||||||
(gen-positive-real (denominator n))))
|
|
||||||
((memv radix (if (exact? n) '(2 8 10 16) '(10)))
|
((memv radix (if (exact? n) '(2 8 10 16) '(10)))
|
||||||
(number->string n radix))
|
(number->string n radix))
|
||||||
(else
|
(else
|
||||||
|
@ -280,12 +276,16 @@
|
||||||
;; Post-process a positive real number with decimal char fixup
|
;; Post-process a positive real number with decimal char fixup
|
||||||
;; and commas as needed.
|
;; and commas as needed.
|
||||||
(define (wrap-comma n)
|
(define (wrap-comma n)
|
||||||
(let* ((s0 (gen-positive-real n))
|
(if (and (not precision) (exact? n) (not (integer? n)))
|
||||||
(s1 (if (or (eqv? #\. dec-sep)
|
(string-append (wrap-comma (numerator n))
|
||||||
(equal? "." dec-sep))
|
"/"
|
||||||
s0
|
(wrap-comma (denominator n)))
|
||||||
(string-replace-all s0 #\. dec-sep))))
|
(let* ((s0 (gen-positive-real n))
|
||||||
(if comma-rule (insert-commas s1) s1)))
|
(s1 (if (or (eqv? #\. dec-sep)
|
||||||
|
(equal? "." dec-sep))
|
||||||
|
s0
|
||||||
|
(string-replace-all s0 #\. dec-sep))))
|
||||||
|
(if comma-rule (insert-commas s1) s1))))
|
||||||
;; Wrap the sign of a real number, forcing a + prefix or using
|
;; Wrap the sign of a real number, forcing a + prefix or using
|
||||||
;; parentheses (n) for negatives according to sign-rule.
|
;; parentheses (n) for negatives according to sign-rule.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue