This isn't smooth, but it works: #lang at-exp racket (first (regexp-match @pregexp{\d+\.\d{0,4}} "15.123456789")) (first (regexp-match @pregexp{\d+\.\d{0,4}} "15.12"))
On Thu, May 25, 2017 at 7:59 AM, Alasdair McAndrew <amc...@gmail.com> wrote: > In (standard) Racket, I can display a real number x to (say) 4 decimal > places using something like > > (displayln (string->number (real->decimal-string x 4))) > > This is handy for printing out multiple versions of a list or vector of > real numbers, and seeing how they change. > > I would like to do the same thing with a BigFloat. I can convert it to a > string, but the "bigfloat->string" construct doesn't have an extra > parameter to limit the number of displayed decimal places. Is there a > simple way of displaying a bigfloat with only a limited number of decimal > places? > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.