numformat-old: Number Formatting
(requirenumformat-old) | package:numformat-old |
1 Introduction
The numformat-old package contains some old and highly-questionable Scheme number-formatting code, which happens to still be used. Do not use this for anything important. A better modern Racket implementation of this functionality should be done.
2 Interface
procedure
→ (-> number? (output-port? (current-output-port)) void?) specs : (listof (cons/c symbol? any/c))
> (define display-dollars-and-cents (make-number-displayer '((sign parens) (prefix "$") (pad-whole-char #f) (pad-whole-length #f) (whole-spacers-char #\,) (whole-spacers-interval 3) (decimal-point #\.) (max-fractional-length 2) (pad-fractional-char #\0) (pad-fractional-length 2) (suffix #f))))
> (display-dollars-and-cents 69.1)
$69.10 |
> (display-dollars-and-cents -987654321.6969697)
($987,654,321.69) |
procedure
num : number? out : (current-output-port) (display-number/european-style num out) → void? num : number? out : (current-output-port)
> (define x -987654321.6969697)
> (display-number/us-style x)
-987,654,321.6969697 |
> (display-number/european-style x)
-987 654 321,6969697 |
3 History
- Version 2:0 —
2016-02-29 Moving from PLaneT to new package system.
Renaming package from numformat to numformat-old, to avoid grabbing better package name for this old code.
Changed “European-style” to use spaces instead of apostrophes.
- Version 1:0 —
2011-08-23 Initial release of some old, buggy code.
4 Legal
Copyright 2011, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.