<div dir="ltr">

<div class="gmail_quote" style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">2018-08-04 19:35 GMT+08:00 Marc Feeley<span> </span><span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank" style="color:rgb(17,85,204)">feeley@iro.umontreal.ca</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><br>> On Aug 4, 2018, at 11:14 AM, Adam <<a href="mailto:adam.mlmb@gmail.com" style="color:rgb(17,85,204)">adam.mlmb@gmail.com</a>> wrote:<br>><span> </span><br>> Hi,<br>><span> </span><br>> How do you do Log N, Log 2 and Log 10 in Gambit?<br>><span> </span><br>> Thanks!<br>> Adam<br><br></div></div>> (exp 1)<br>2.718281828459045<br>> (log (exp 1))<br>1.<br>> (/ (log 1000) (log 10))<br>2.9999999999999996<br>> (/ (log 1024) (log 2))<br>10.<br></blockquote><div><br></div><div>While this may understandably appear trivial for you, would you mind to give one minute to spell out the code for</div><div><br></div><div>(define (log2 n) ...)</div><div>(define (log10 n) ...)</div><div>(define (logn n base) ...)</div><div><br></div><div>?</div></div><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> (- (integer-length 1024) 1)<br>
10<br>
<br>
The procedure integer-length can be useful for exact integers if you want an exact integer result.<br></blockquote><div><br></div><div>

<div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">Ah interesting, |integer-length| counts an exact integer's significant bits</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><div>> (integer-length 1)</div><div>1</div><div>> (integer-length 2)</div><div>2</div><div>> (integer-length 4)</div><div>3</div><div>> (integer-length 8)</div><div>4</div><div>> (integer-length 16)</div><div>5</div></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">Right, so this gives us something like, for |n| > 0,</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial">(define (integer-log2 n) (- (integer-length n) 1))</div><div style="font-size:small;text-decoration-style:initial;text-decoration-color:initial"><br></div></div></div></div>