search

goog.math.Long

Module ID

Represents a 64-bit two's-complement integer, given its low and high 32-bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs.

The internal representation of a long is the two given signed, 32-bit values. We use 32-bit pieces because these are the size of integers on which JavaScript performs bit-operations. For operations like addition and multiplication, we split each number into 16-bit pieces, which can easily be multiplied within JavaScript's floating-point representation without overflow or change in sign.

In the algorithms below, we frequently reduce the negative case to the positive case by negating the input(s) and then post-processing the result. Note that we must ALWAYS check specially whether those values are MIN_VALUE (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as a positive number, it overflows back into a negative). Not handling this case would often result in infinite recursion.

new Long( arg0, arg1 )

Parameters
arg0number
arg1number

Instance Methods

Exported Functions