[racket-dev] Preserving trailing zeros in formatting numbers as strings

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Fri May 2 16:52:20 EDT 2014

On 2014-04-24 05:25:07 -0400, Kathi Fisler wrote:
>    I'm generating class notes in HTML via scribble.  I'm trying to include
>    the number 10.50 (as a price in an test case, so the trailing 0 matters).
>     I'm using format to produce the strings that go into the rendered html.
>     When I do this (whether with ~a or ~s), the trailing 0 is dropped,
>    producing 10.5 in my output instead of 10.50.  

Maybe this is too late to be useful (I think the mailing list ate your
post?), but here's one way to do it:

  > (~r 10.5 #:precision '(= 2))
  "10.50"

Cheers,
Asumu

Posted on the dev mailing list.