A simple, lightweight npm package to determine if a number is odd. This package provides a blazingly fast alternative to existing solutions like the `is-odd` package by leveraging bitwise operations.
You can install the package using npm:
npm install blazingly-fast-is-odd
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
checkIfOdd(number)
- Parameters
-
number
: The number to check (can be an integer).
-
- Returns
-
true
if the number is odd,false
if it is even.
-
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.
GPL-3.0-or-later License. See LICENSE for details.
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.