[plt-scheme] Specifying number precision to display

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Sun Aug 22 21:57:47 EDT 2004

Awhile ago, in response to a cookbook question, I wrote most of a small
number-formatting library, but wanted to rethink the API, so I never
polished up the code for release.  Should I add this back on my TODO
list?


(load "numberformat.scm")

(define display-number-my-way
  ;; Most of these are defaults that could be left out.
  (make-number-displayer
   '((sign                   minus)
     (prefix                 #f)
     (pad-whole-char         #f)
     (pad-whole-length       #f)
     (whole-spacers-char     #\,)
     (whole-spacers-interval 3)
     (decimal-point          #\.)
     (max-fractional-length  4)
     (pad-fractional-char    #\0)
     (pad-fractional-length  #f)
     (suffix                 #f))))

(display-number-my-way -87654321.69696969)

-87,654,321.6969


-- 
                                             http://www.neilvandyke.org/


Posted on the users mailing list.