time-to-botec

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

README.md (1993B)


      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 # Square Root
     22 
     23 > Compute an integer [square root][square-root].
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var sqrtUint32 = require( '@stdlib/math/base/special/fast/uint32-sqrt' );
     37 ```
     38 
     39 #### sqrtUint32( x )
     40 
     41 Returns an **approximate** [square root][square-root] of an unsigned 32-bit integer `x`.
     42 
     43 ```javascript
     44 var v = sqrtUint32( 9 >>> 0 );
     45 // returns 3
     46 
     47 v = sqrtUint32( 2 >>> 0 );
     48 // returns 1
     49 
     50 v = sqrtUint32( 3 >>> 0 );
     51 // returns 1
     52 
     53 v = sqrtUint32( 0 >>> 0 );
     54 // returns 0
     55 ```
     56 
     57 </section>
     58 
     59 <!-- /.usage -->
     60 
     61 <section class="notes">
     62 
     63 ## Notes
     64 
     65 -   Prefer hardware `sqrt` over a software implementation.
     66 -   When using a software `sqrt`, this implementation provides a performance boost when an application requires only **approximate** computations for integer arguments.
     67 -   For applications requiring high-precision, this implementation is **never** suitable.
     68 
     69 </section>
     70 
     71 <!-- /.notes -->
     72 
     73 <section class="examples">
     74 
     75 ## Examples
     76 
     77 <!-- eslint no-undef: "error" -->
     78 
     79 ```javascript
     80 var sqrtUint32 = require( '@stdlib/math/base/special/fast/uint32-sqrt' );
     81 
     82 var v;
     83 var i;
     84 
     85 for ( i = 0; i < 101; i++ ) {
     86     v = sqrtUint32( i >>> 0 );
     87     console.log( 'sqrt(%d) ≈ %d', i, v );
     88 }
     89 ```
     90 
     91 </section>
     92 
     93 <!-- /.examples -->
     94 
     95 <section class="links">
     96 
     97 [square-root]: https://en.wikipedia.org/wiki/Square_root
     98 
     99 </section>
    100 
    101 <!-- /.links -->