blazingly-fast-is-odd
v1.0.5
Published
Blazingly fast package to check if number is odd
Downloads
11
Readme
Check If Odd
Installation
You can install the package using npm:
npm install blazingly-fast-is-odd
Usage
To use the checkIfOdd function, require the package in your JavaScript code:
const { checkIfOdd } = require('check-if-odd');
console.log(checkIfOdd(3)); // true
console.log(checkIfOdd(4)); // false
console.log(checkIfOdd(-5)); // true
console.log(checkIfOdd(-6)); // false
Function Signature
checkIfOdd(number)
- Parameters
number
: The number to check (can be an integer).
- Returns
true
if the number is odd,false
if it is even.
Performance
The chekIfOdd
function uses a bitwise operation (number & 1
) to determine if a number is odd. This method is typically faster than using modulus (number % 2
) because bitwise operations are generally more efficient at the processor level.
License
GPL-3.0-or-later License. See LICENSE for details.
Contributing
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.