@sollentson/is-odd
v1.0.7
Published
Returns true if the given number is odd, and is an integer that does not exceed the JavaScript MAXIMUM_SAFE_INTEGER.
Downloads
8
Maintainers
Readme
isOdd Function
You can check the performance in my repository or write your own tests In my case it came out to 1 million iterations:
The isOdd
function is a JavaScript utility that determines whether a given number is odd. It performs the following checks before returning the result:
- Validates that the input is a number.
- Ensures that the number is an integer.
- Verifies that the number does not exceed the maximum safe integer in JavaScript.
The function then uses a bitwise operation to check if the absolute value of the number is odd, and returns true
if it is, and false
if it's even.
Usage
The isOdd
function can be used as follows:
import { isOdd } from '@sollentson/is-odd';
console.log(isOdd(3)); // Output: true
console.log(isOdd(4)); // Output: false
Installation
You can install the @sollentson/is-odd
package using npm:
$ npm install @sollentson/is-odd
License
This function is provided under the MIT License. Please see the LICENSE file for more details.
For any issues or feature requests, please create an issue on the BitBucket repository.
If you have any further questions or need additional information, feel free to ask! [email protected]