compute-intmin
v1.0.0
Published
Returns the minimum value of a specified integer type.
Downloads
9
Maintainers
Readme
intmin
Returns the minimum value of a specified integer type.
Installation
$ npm install compute-intmin
For use in the browser, use browserify.
Usage
var intmin = require( 'compute-intmin' );
intmin( [type] )
Returns the minimum value of a specified integer
type.
var min = intmin( 'int8' );
// returns -128
The following integer
types are supported:
- int8: signed 8-bit integer
- uint8: unsigned 8-bit integer
- int16: signed 16-bit integer
- uint16: unsigned 16-bit integer
- int32: signed 32-bit integer
- uint32: unsigned 32-bit integer
If not provided an integer type
, the function returns the minimum signed 32-bit integer.
intmin() === intmin( 'int32' );
// returns true
Examples
var intmin = require( 'compute-intmin' ),
min;
// int32 (default):
min = intmin();
// returns -2147483648
// int8:
min = intmin( 'int8' );
// returns -128
// int16:
min = intmin( 'int16' );
// returns -32768
// int32:
min = intmin( 'int32' );
// returns -2147483648
// uint8:
min = intmin( 'uint8' );
// returns 0
// uint16:
min = intmin( 'uint16' );
// returns 0
// uint32:
min = intmin( 'uint32' );
// returns 0
To run the example code from the top-level application directory,
$ node ./examples/index.js
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2015. The Compute.io Authors.