<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">This is interesting behavior. To explain why it happens, this has something to do with how the HtDP languages handle exact/inexact numbers. For example, in plain Racket, <font face="Courier" class="">(exact? 0.75)</font> is <font face="Courier" class="">#f</font>, but in BSL, it is <font face="Courier" class="">#true</font>. In BSL, numbers are exact unless otherwise specified. Note that explicitly using an exactness prefix in plain Racket, <font face="Courier" class="">#e0.75</font>, produces <font face="Courier" class="">3/4</font>.</div><div class=""><br class=""></div><div class="">What’s odd is that the convention for printing numbers in BSL is different from the convention used by <font face="Courier" class="">number->string</font>. BSL, unlike Racket, prints exact numbers as decimals. I’d expect that this is to avoid confusion when students type in decimals only to have them printed in large fractions. Unfortunately, it would seem that <font face="Courier" class="">number->string</font> simply uses the plain Racket implementation, which lets the odd implementations details “leak through” the abstraction.</div><div class=""><br class=""></div><div class="">It does feel like poor behavior to me. I’d expect <font face="Courier" class="">number->string</font> to follow the same printing conventions BSL uses.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 18, 2015, at 00:17, Breanndán Ó Nualláin <<a href="mailto:bon@science.uva.nl" class="">bon@science.uva.nl</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">In BSL, I just got caught out by this behaviour:<br class=""><br class=""><blockquote type="cite" class="">(number->string 0.75)<br class=""></blockquote> "3/4"<br class=""><br class="">I expected the same behaviour as in the full Racket language:<br class=""><br class=""><blockquote type="cite" class="">(number->string 0.75)<br class=""></blockquote> "0.75"<br class=""><br class="">What's the thinking behind this? Wouldn't the decimal notation be more intuitive, particularly in cases like this?<br class=""><br class=""><blockquote type="cite" class="">(number->string 0.7555555)<br class=""></blockquote> "1511111/2000000"<br class=""><br class="">And especially in cases like this?<br class=""><br class=""><blockquote type="cite" class="">(number->string (string->number (number->string pi)))<br class=""></blockquote> "3141592653589793/1000000000000000"<br class="">____________________<br class=""> Racket Users list:<br class=""> <a href="http://lists.racket-lang.org/users" class="">http://lists.racket-lang.org/users</a><br class=""></div></blockquote></div><br class=""></body></html>