On Thursday, 25 May 2017 23:44:58 UTC+10, David K. Storrs wrote: > 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")) > Thank you - that is certainly more complicated than I though it would be. Another way would be to create a new real number, something like
(exact->inexact (bigfloat->real x)) and then apply the conversion to and from a string to it. For example: > (require math/bigfloat) > (bf-precision 255) > (define x (bfsqrt (bf 3))) > x (bf #e1.73205080756887729352744634150587236694280525381038062805580697945193301690881) > (displayln (string->number (real->decimal-string (exact->inexact > (bigfloat->real x)) 4 ))) 1.732 I was just hoping there might be something neater! -- 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.