<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-GB" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi – there is a countLeadingZeros function. It applies to instances of FiniteBits, such as Int (a fixed bit-size integer):</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">Loaded package environment from C:\Users\David\AppData\Roaming\ghc\x86_64-mingw32-8.10.7\environments\default<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> :m +Data.Bits<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">> countLeadingZeros (23 :: Int)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">59<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The Integer type represents unbounded integers, so countLeadingZeros doesn’t really make sense.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">(ps. you can seach for functions like countLeadingZeros on <a href="https://hoogle.haskell.org/">
Hoogle</a>).</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hope that helps, David.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="border:none;padding:0cm"><b>From: </b><a href="mailto:james.faure@epitech.eu">james faure</a><br>
<b>Sent: </b>13 November 2021 00:16<br>
<b>To: </b><a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br>
<b>Subject: </b>[Haskell-cafe] clz / bsr functions on Integer</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black">Why is there no `countLeadingZeros` function for Integer? This seems particularly strange because gmp provides </span><em><span style="font-size:13.5pt;color:black">mp_bitcnt_t</span></em><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black"> <strong>mpz_scan0</strong> <em>(const
 mpz_t </em><var>op</var><em>, mp_bitcnt_t </em><var>starting_bit</var><em>)</em></span><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:13.5pt;color:black">More importantly, what is the recommended way to access it?</span><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>