Bug in srfi-48? Donald Allen (11 Oct 2017 19:42 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (11 Oct 2017 19:46 UTC)
Re: Bug in srfi-48? Donald Allen (11 Oct 2017 20:36 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (11 Oct 2017 21:33 UTC)
Re: Bug in srfi-48? Donald Allen (12 Oct 2017 13:04 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (12 Oct 2017 19:07 UTC)
Re: Bug in srfi-48? Donald Allen (12 Oct 2017 19:42 UTC)
Re: Bug in srfi-48? Shiro Kawai (12 Oct 2017 20:40 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (12 Oct 2017 23:13 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 02:09 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 15:58 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 16:13 UTC)
Re: Bug in srfi-48? Marc Feeley (13 Oct 2017 17:50 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 17:52 UTC)
Re: Bug in srfi-48? Shiro Kawai (13 Oct 2017 19:54 UTC)
Re: Bug in srfi-48? John Cowan (13 Oct 2017 17:34 UTC)
Re: Bug in srfi-48? Donald Allen (13 Oct 2017 17:51 UTC)
Re: Bug in srfi-48? Alex Shinn (14 Oct 2017 13:03 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (14 Oct 2017 13:11 UTC)
Re: Bug in srfi-48? Arthur A. Gleckler (18 Oct 2017 18:20 UTC)
Re: Bug in srfi-48? Donald Allen (18 Oct 2017 19:11 UTC)

Re: Bug in srfi-48? Donald Allen 13 Oct 2017 17:52 UTC

On 13 October 2017 at 13:51, Marc Feeley <xxxxxx@iro.umontreal.ca> wrote:
> I’ve found this code works well for me…
>
> (define (num->string num w d) ; w = total width, d = decimals
>  (let ((n (round (* (abs (inexact->exact num)) (expt 10 d)))))
>    (let ((i (quotient n (expt 10 d)))
>          (f (modulo n (expt 10 d))))
>      (let ((si (string-append
>                  (if (< num 0) "-" "")
>                  (number->string i 10)))
>            (sf (if (> d 0)
>                    (let ((sf (number->string (+ f (expt 10 d)) 10)))
>                      (string-set! sf 0 #\.)
>                      sf)
>                    "")))
>        (let ((lsi (string-length si))
>              (lsf (string-length sf)))
>          (let ((blanks (- w (+ lsi lsf))))
>            (string-append (make-string (max blanks 0) #\space) si sf)))))))
>
> Perhaps that’s better for your purpose than srfi-48.

Thank you. I will give it a try.

/Don