mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
fixing formatting with 0 precision
This commit is contained in:
parent
dec0f3b1a5
commit
79f08129b2
1 changed files with 3 additions and 1 deletions
|
@ -134,7 +134,7 @@
|
||||||
(let ((res (- (char->integer ch) (char->integer #\0))))
|
(let ((res (- (char->integer ch) (char->integer #\0))))
|
||||||
(if (<= 0 res 9)
|
(if (<= 0 res 9)
|
||||||
res
|
res
|
||||||
ch)))
|
0)))
|
||||||
(define (round-up ls)
|
(define (round-up ls)
|
||||||
(let lp ((ls ls) (res '()))
|
(let lp ((ls ls) (res '()))
|
||||||
(cond
|
(cond
|
||||||
|
@ -199,6 +199,8 @@
|
||||||
;; result of string->number.
|
;; result of string->number.
|
||||||
(define (gen-fixed n)
|
(define (gen-fixed n)
|
||||||
(cond
|
(cond
|
||||||
|
((and (eqv? radix 10) (zero? precision) (inexact? n))
|
||||||
|
(number->string (exact (round n))))
|
||||||
((and (eqv? radix 10) (or (integer? n) (inexact? n)))
|
((and (eqv? radix 10) (or (integer? n) (inexact? n)))
|
||||||
(let* ((s (number->string n))
|
(let* ((s (number->string n))
|
||||||
(end (string-cursor-end s))
|
(end (string-cursor-end s))
|
||||||
|
|
Loading…
Add table
Reference in a new issue