Class: LongBits

util. LongBits

Helper class for working with the low and high bits of a 64 bit value.

new util.LongBits(lo, hi)

Constructs new long bits.

Name Type Description
lo number

Low 32 bits, unsigned

hi number

High 32 bits, unsigned

Members

util.LongBits.zero { util.LongBits }

Zero bits.

util.LongBits.zeroHash { string }

Zero hash.

hi { number }

High bits.

lo { number }

Low bits.

Methods

util.LongBits.from(value){ util.LongBits }

Constructs new long bits from a number, long or string.

Name Type Description
value Long | number | string

Value

Returns:
Type Description
util.LongBits Instance

util.LongBits.fromHash(hash){ util.LongBits }

Constructs new long bits from the specified 8 characters long hash.

Name Type Description
hash string

Hash

Returns:
Type Description
util.LongBits Bits

util.LongBits.fromNumber(value){ util.LongBits }

Constructs new long bits from the specified number.

Name Type Description
value number

Value

Returns:
Type Description
util.LongBits Instance

length(){ number }

Calculates the length of this longbits when encoded as a varint.

Returns:
Type Description
number Length

toHash(){ string }

Converts this long bits to a 8 characters long hash.

Returns:
Type Description
string Hash

toLong(unsigned){ Long }

Converts this long bits to a long.

Name Type Default Description
unsigned boolean false optional

Whether unsigned or not

Returns:
Type Description
Long Long

toNumber(unsigned){ number }

Converts this long bits to a possibly unsafe JavaScript number.

Name Type Default Description
unsigned boolean false optional

Whether unsigned or not

Returns:
Type Description
number Possibly unsafe number

Zig-zag decodes this long bits.

Returns:
Type Description
util.LongBits this

Zig-zag encodes this long bits.

Returns:
Type Description
util.LongBits this