Re: Bug in srfi-48?
Donald Allen <[email protected]> Fri, 13 Oct 2017 13:52:40 -0400
| Newsgroups | gmane.lisp.scheme.srfi.srfi-48 |
|---|---|
| Message-ID | <CAPsTYbz+gdEzRBXnp=7KyObdV07Agp7uqaoV4rgyhb0512Ki9Q@mail.gmail.com> |
On 13 October 2017 at 13:51, Marc Feeley <[email protected]> wrote: > I=E2=80=99ve found this code works well for me=E2=80=A6 > > (define (num->string num w d) ; w =3D total width, d =3D 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=E2=80=99s better for your purpose than srfi-48. Thank you. I will give it a try. /Don