racket / htdp

Other
93 stars 70 forks source link

[feature request] ~r like function #108

Closed sorawee closed 4 years ago

sorawee commented 4 years ago

(number->string 0.80) results in "4/5", which is usually not a format suitable for display. Although we can hack it with (number->string (exact->inexact 0.80)) to get 0.8, it's still not possible to pad 0s or truncate excessive fractional part of a decimal.

It would be nice to have a function similar to ~r from Racket in student languages so that numbers can be formatted easily.

sorawee commented 4 years ago

Pyret has num-to-string-digits, FWIW.