Coder Social home page Coder Social logo

stdlib-js / math-base-special-imul Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 146 KB

Perform C-like multiplication of two signed 32-bit integers.

Home Page: https://github.com/stdlib-js/stdlib

License: Apache License 2.0

JavaScript 35.20% Makefile 45.08% C 19.72%
nodejs javascript stdlib node node-js mathematics math imul multiplication multiply

math-base-special-imul's Introduction

Attention

⚠️ This package has been renamed. Use @stdlib/math-base-ops-imul instead. ⚠️



imul

NPM version Build Status Coverage Status dependencies

Perform C-like multiplication of two signed 32-bit integers.

Installation

npm install @stdlib/math-base-special-imul

Usage

var imul = require( '@stdlib/math-base-special-imul' );

imul( a, b )

Performs C-like multiplication of two signed 32-bit integers.

var v = imul( -10|0, 4|0 );
// returns -40

v = imul( 1073741824|0, -5|0 ); // 2^30 * -5 = -5368709120 => 32-bit integer overflow
// returns -1073741824

Notes

  • The function emulates C-like multiplication of two signed 32-bit integers.

Examples

var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory;
var INT32_MIN = require( '@stdlib/constants-int32-min' );
var INT32_MAX = require( '@stdlib/constants-int32-max' );
var imul = require( '@stdlib/math-base-special-imul' );

var randi;
var a;
var b;
var y;
var i;

randi = discreteUniform( INT32_MIN, INT32_MAX );

for ( i = 0; i < 100; i++ ) {
    a = randi()|0;
    b = randi()|0;
    y = imul( a, b );
    console.log( '%d x %d = %d', a, b, y );
}

See Also


Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2021. The Stdlib Authors.

math-base-special-imul's People

Contributors

stdlib-bot avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.