README.md (2015B)
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 # uimul 22 23 > Perform C-like multiplication of two unsigned 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 uimul = require( '@stdlib/math/base/special/uimul' ); 37 ``` 38 39 #### uimul( a, b ) 40 41 Performs C-like multiplication of two unsigned 32-bit integers. 42 43 ```javascript 44 var v = uimul( 10>>>0, 4>>>0 ); 45 // returns 40 46 47 v = uimul( 2147483648>>>0, 5>>>0 ); // 2^31 * 5 = 10737418240 => 32-bit integer overflow 48 // returns 2147483648 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 unsigned 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 UINT32_MAX = require( '@stdlib/constants/uint32/max' ); 76 var uimul = require( '@stdlib/math/base/special/uimul' ); 77 78 var randi; 79 var a; 80 var b; 81 var y; 82 var i; 83 84 randi = discreteUniform( 0, UINT32_MAX ); 85 86 for ( i = 0; i < 100; i++ ) { 87 a = randi()>>>0; 88 b = randi()>>>0; 89 y = uimul( a, b ); 90 console.log( '%d x %d = %d', a, b, y ); 91 } 92 ``` 93 94 </section> 95 96 <!-- /.examples --> 97 98 <section class="links"> 99 100 </section> 101 102 <!-- /.links -->