time-to-botec

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

README.md (2056B)


      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 # imul
     22 
     23 > Perform C-like multiplication of two signed 32-bit integers.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var imul = require( '@stdlib/math/base/special/imul' );
     37 ```
     38 
     39 #### imul( a, b )
     40 
     41 Performs C-like multiplication of two signed 32-bit integers.
     42 
     43 ```javascript
     44 var v = imul( -10|0, 4|0 );
     45 // returns -40
     46 
     47 v = imul( 1073741824|0, -5|0 ); // 2^30 * -5 = -5368709120 => 32-bit integer overflow
     48 // returns -1073741824
     49 ```
     50 
     51 </section>
     52 
     53 <!-- /.usage -->
     54 
     55 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     56 
     57 <section class="notes">
     58 
     59 ## Notes
     60 
     61 -   The function emulates C-like multiplication of two signed 32-bit integers.
     62 
     63 </section>
     64 
     65 <!-- /.notes -->
     66 
     67 <section class="examples">
     68 
     69 ## Examples
     70 
     71 <!-- eslint no-undef: "error" -->
     72 
     73 ```javascript
     74 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
     75 var INT32_MIN = require( '@stdlib/constants/int32/min' );
     76 var INT32_MAX = require( '@stdlib/constants/int32/max' );
     77 var imul = require( '@stdlib/math/base/special/imul' );
     78 
     79 var randi;
     80 var a;
     81 var b;
     82 var y;
     83 var i;
     84 
     85 randi = discreteUniform( INT32_MIN, INT32_MAX );
     86 
     87 for ( i = 0; i < 100; i++ ) {
     88     a = randi()|0;
     89     b = randi()|0;
     90     y = imul( a, b );
     91     console.log( '%d x %d = %d', a, b, y );
     92 }
     93 ```
     94 
     95 </section>
     96 
     97 <!-- /.examples -->
     98 
     99 <section class="links">
    100 
    101 </section>
    102 
    103 <!-- /.links -->