
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Used to perform basic math operations against different base numbering systems.
base-math is a package that performs basic mathematical operations regardless of number base. When provided a respective base (binary, octal, hex) base-math will convert the provided numbers to integers, perform the operation, and return the result in requested base.
npm install base-math --save
var bmath = require('base-math')();
base-math takes two required parameters and one optional base parameter. For example, bmath.add('101', '1221', 8) would return 1322 in base 8. The package defaults to a base 10 numbering system so that the same operation bmath.add('101', '1221') without a base type would also result in 1322 with an entirely different meaning. Basically, be aware of what you're converting.
At this time, base-math does not support mixed number types. Both numbers should be of the same base.
add(x, y, base)
Adds two numbers and returns the result. Takes an optional base parameter. Defaults to base 10.
var hexNum = bmath.add('3e2a', '1e1d', 16);
var octNum = bmath.add('363', '031', 8);
var binary = bmath.add('11001101', '10101110', 2);
var float = bmath.add(4.3, 3.2);
var number = bmath.add(45, 21);
subtract(x, y, base)
Subtracts two numbers and returns the result. Takes an optional base parameter. Defaults to base 10.
var hexNum = bmath.subtract('3e2a', '1e1d', 16);
var octNum = bmath.subtract('363', '031', 8);
var binary = bmath.subtract('11001101', '10101110', 2);
var float = bmath.subtract(4.3, 3.2);
var number = bmath.subtract(45, 21);
divide(x, y, base)
Divides two numbers and returns the result. Takes an optional base parameter. Defaults to base 10.
var hexNum = bmath.divide('3e2a', '1e1d', 16);
var octNum = bmath.divide('363', '031', 8);
var binary = bmath.divide('11001101', '10101110', 2);
var float = bmath.divide(4.3, 3.2);
var number = bmath.divide(45, 21);
multiply(x, y, base)
Multiplies two numbers and returns the result. Takes an optional base parameter. Defaults to base 10.
var hexNum = bmath.multiply('3e2a', '1e1d', 16);
var octNum = bmath.multiply('363', '031', 8);
var binary = bmath.multiply('11001101', '10101110', 2);
var float = bmath.multiply(4.3, 3.2);
var number = bmath.multiply(45, 21);
sqrt(x, y, base)
Returns the square root of a number. If an integer, returns the value as a float. Takes an optional number base parameter. Defaults to base 10.
var hexNum = bmath.sqrt('3e2a', 16);
var octNum = bmath.sqrt('363',8);
var binary = bmath.sqrt('11001101', 2);
var float = bmath.sqrt(4.3);
var number = bmath.sqrt(45);
pow(x, y, base)
Returns the power of two numbers. X is base number and Y is the exponent. The exponent is a real number in base 10 (for example, 2 or 2.13). Takes an optional number base parameter. Defaults to base 10.
var hexNum = bmath.pow('3e2a', 3, 16);
var octNum = bmath.pow('363', 2, 8);
var binary = bmath.pow('11001101', 3, 2);
var float = bmath.pow(4.3, 2);
var number = bmath.pow(2, 8);
base-math performs a check to see if either of the parameters or the product of the parameters exceeds the MAX_SAFE_INTEGER. If so, a message is written to the console.log.
base-math performs a check to see if either of the parameters or the product of the parameters is less than the MIN_SAFE_INTEGER. If so, a message is written to the console.log.
If either of the parameters or the product of the parameters exceeds the MAX_VALUE base-math returns 'Infinity'
FAQs
Used to perform basic math operations against different base numbering systems.
We found that base-math demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.