To find the behavior closer to the C function printf() , use the format procedure provided by SRFI-48 , for example:
(require srfi/48) (format "The area of the disk is ~6,2F~%" (- d1 d2))
A more complex alternative would be to use the ~r routine built into Racket, as suggested by @stchang:
(string-append "The area of the disk is " (~r (- d1 d2) #:min-width 6 #:precision '(= 2)) "\n")
source share