time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (1898B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # Binary Logarithm
     22 
     23 > Compute an integer [binary logarithm][binary-logarithm].
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var log2Uint32 = require( '@stdlib/math/base/special/fast/uint32-log2' );
     37 ```
     38 
     39 #### log2Uint32( x )
     40 
     41 Returns an **approximate** [binary logarithm][binary-logarithm] of an unsigned 32-bit integer `x`.
     42 
     43 ```javascript
     44 var v = log2Uint32( 4 >>> 0 );
     45 // returns 2
     46 
     47 v = log2Uint32( 8 >>> 0 );
     48 // returns 3
     49 
     50 v = log2Uint32( 9 >>> 0 );
     51 // returns 3
     52 ```
     53 
     54 </section>
     55 
     56 <!-- /.usage -->
     57 
     58 <section class="notes">
     59 
     60 ## Notes
     61 
     62 -   This implementation provides a performance boost when an application requires only **approximate** computations for integer arguments.
     63 -   For applications requiring high-precision, this implementation is **never** suitable.
     64 
     65 </section>
     66 
     67 <!-- /.notes -->
     68 
     69 <section class="examples">
     70 
     71 ## Examples
     72 
     73 <!-- eslint no-undef: "error" -->
     74 
     75 ```javascript
     76 var log2Uint32 = require( '@stdlib/math/base/special/fast/uint32-log2' );
     77 
     78 var v;
     79 var i;
     80 
     81 for ( i = 1; i < 101; i++ ) {
     82     v = log2Uint32( i >>> 0 );
     83     console.log( 'log2(%d) ≈ %d', i, v );
     84 }
     85 ```
     86 
     87 </section>
     88 
     89 <!-- /.examples -->
     90 
     91 <section class="links">
     92 
     93 [binary-logarithm]: https://en.wikipedia.org/wiki/Binary_logarithm
     94 
     95 </section>
     96 
     97 <!-- /.links -->