BitStringHelper
Index
Constructors
constructor
Returns BitStringHelper
Methods
staticcanFitSigned
Parameters
value: number
an integer. The value to be encoded.
bits: number
a non-negative integer between 0 and
SAFE_INTEGER_BITS, inclusive. The amount of bits the value should be encoded in.
Returns boolean
Whether we can encode a signed
valueinbitsbits.
staticcanFitUnsigned
Parameters
value: number
a non-negative integer. The value to be encoded.
bits: number
a non-negative integer between 0 and
SAFE_INTEGER_BITS, inclusive. The amount of bits the value should be encoded in.
Returns boolean
Whether we can encode an unsigned
valueinbitsbits.
staticgetBitsCountForSigned
Parameters
value: number
an integer. The value to be encoded.
Returns number
The minimal amount of bits required to encode a given signed value. For zero values returns zero.
staticgetBitsCountForUnsigned
Parameters
value: number
a non-negative integer. The value to be encoded.
Returns number
The minimal amount of bits required to encode a given unsigned value. For zero values returns zero.
staticmaxSignedInBits
The maximum signed number which can fit into a given number of bits.
Parameters
bits: number
Returns number
staticmaxUnsignedInBits
The maximum unsigned number which can fit into a given number of bits.
Parameters
bits: number
Returns number
staticminSignedInBits
The minimum signed number which can fit into a given number of bits.
Parameters
bits: number
Returns number
A collection of helper functions used throughout the module. They should be used by the users when working with dynamically-sized fields.