binaryarray
Version:
the binary array
28 lines (27 loc) • 777 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// Number of bit
var BITS = 32;
/**
* Returns the bit size defined by this module.
* @returns bit size
*/
exports.getBitSize = function () { return BITS; };
/**
* Calculate the array length from the number of flags
* @param flagmax max bits
* @returns array length
*/
exports.getArraySize = function (flagmax) { return Math.ceil(flagmax / BITS); };
/**
* Find the position of the array from the flag number
* @param no flag number
* @returns array index
*/
exports.getArrayIndex = function (no) { return Math.floor(no / BITS); };
/**
* Find the bit position from the flag number
* @param no flag number
* @returns bit index
*/
exports.getFlagPos = function (no) { return no % BITS; };