An ActionScript3 equivalent to the signed 64bits
long type
in Java. All arithmetic operations are provided, as well as bitwise, bit
shift and comparison operator equivalents.
This class provides externalization methods that are meant to be used
with specific GraniteDS serialization mechanisms. Its main purpose is to
give a reliable serialization behavior between ActionScript3 and Java
long type: standard serialization uses the ActionScript3
Number type, with possible lose of precision.
highBits:uint [read-only]
The high 32bits of this Long as an uint.
Implementation
public function get highBits():uint
lowBits:uint [read-only]
The low 32bits of this Long as an uint.
Implementation
public function get lowBits():uint
sign:int [read-only]
The sign of this Long as an int, ie:
-1, 0 or 1 as the value of this Long is negative,
zero or positive.
Implementation
public function get sign():int
public function Long(value:* = null, radix:int = 10)
Constructs a new Long instance according to the
supplied parameters.
The value parameter may be a String representation of
an integer, a int primitive value, a Number
or even another Long:
String: it must be a not empty String in the form of
-?[0-9a-zA-Z]+ (ie: an optional '-' character followed by
a not empty sequence of digits (with radix >= 2 and <= 36)). When
a String value is used, the second parameter radix
is also used, and the supplied digits must be in accordance with
the specified radix.
int: a primitive integer value (radix ignored).
Number: a primitive number value (radix ignored). Only
the fixed part of the number will be used (decimal part is
ignored).
Long: the new Long will be an exact copy of
the specified parameter.
null: the new Long will be an exact copy of
the constant Long.ZERO.
Parameters
| value:* (default = null) — the value to be assigned to the new Long.
|
| |
| radix:int (default = 10) — the radix (2 <= radix <= 36) to be used for string conversion
(ignored if the value parameter isn't a string).
|
Throws
| NumberFormatError — if the value
parameter is an invalid String representation or it doesn't fit into
a signed 64bits type.
|
| |
| IllegalArgumentError — if the value
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function abs():Long
Returns a Long whose value is the absolute value
of this Long.
Returns
| Long —
the absolute value of this Long.
|
public function add(b:*):Long
Returns a Long whose value is (this + b),
with a possible overflow (silently ignored, as in primitive operations).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value to be added to this Long.
|
Returns
Throws
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function and(b:*):Long
Returns (this & b) (bitwise AND).
Parameters
| b:* — the other operand used in the operation (may be of any type
accepted by the Long constructor).
|
Returns
public function clearBit(index:int):Long
Returns a Long whose value is equivalent to this Long
with the designated bit cleared: computes (this & ~(1 << n)).
Parameters
| index:int — the index of bit to clear.
|
Returns
Throws
public function compareTo(b:Long):int
Compares this Long with the specified
Long. This method is provided in preference to
individual methods for each of the six boolean comparison operators
(<, ==, >, <=, !=, >=). The suggested idiom for performing
these comparisons is: (x.compareTo(y) <op> 0),
where <op> is one of the six comparison operators.
Parameters
| b:Long — the Long to which this Long
is to be compared.
|
Returns
| int — -1, 0 or 1 as this Long is numerically less than,
equal to, or greater than b.
|
public function divide(b:*):Long
Returns a Long whose value is (this / b).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value by which this Long is to be divided.
|
Returns
Throws
| ArithmeticError — if the b
parameter is equals to 0.
|
| |
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function divideAndRemainder(b:*):Array
Returns an array of two Long containing
(this / b) followed by (this % b).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value by which this Long is to be divided,
and the remainder computed.
|
Returns
| Array — an array of two Long: the quotient (this / val)
is the initial element, and the remainder (this % val)
is the final element.
|
Throws
| ArithmeticError — if the b
parameter is equals to 0.
|
| |
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function equals(b:*):Boolean
Compares this Long with the specified object
for equality.
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — an object to which this Long is to
be compared.
|
Returns
| Boolean — true if and only if the specified object is
a Long (or convertible to a
Long) whose value is numerically equal
to this Long.
|
public function leftShift(value:uint):Long
Returns (this << b) (bitwise left shift).
Parameters
Returns
public function multiply(b:*):Long
Returns a Long whose value is (this * b),
with a possible overflow (silently ignored, as in primitive operations).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value to be multiplied by this Long.
|
Returns
Throws
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function negate():Long
Returns a Long whose value is (-this).
Returns
public function not():Long
Returns (~this) (bitwise NOT).
Returns
public function or(b:*):Long
Returns (this | b) (bitwise OR).
Parameters
| b:* — the other operand used in the operation (may be of any type
accepted by the Long constructor).
|
Returns
public function remainder(b:*):Long
Returns a Long whose value is (this % b).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value by which this Long is to be divided,
and the remainder computed.
|
Returns
Throws
| ArithmeticError — if the b
parameter is equals to 0.
|
| |
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function rightShift(value:uint, unsigned:Boolean = false):Long
Returns (this >> b) (bitwise right shift).
Parameters
| value:uint |
| |
| unsigned:Boolean (default = false) |
Returns
public function setBit(index:int):Long
Returns a Long whose value is equivalent to this Long
with the designated bit set: computes (this | (1 << n)).
Parameters
| index:int — the index of bit to set.
|
Returns
Throws
public function subtract(b:*):Long
Returns a Long whose value is (this - b),
with a possible overflow (silently ignored, as in primitive operations).
The b parameter may be of any of the supported types as
specified in the Long constructor documentation
(a radix of 10 is assumed for String representations).
Parameters
| b:* — the value to be subtracted from this Long.
|
Returns
Throws
| NumberFormatError — if the b
parameter is an invalid String representation (for radix 10).
|
| |
| IllegalArgumentError — if the b
parameter is not one of the supported types or if it is
Number.NaN, Number.POSITIVE_INFINITY or
Number.NEGATIVE_INFINITY.
|
public function testBit(index:int):Boolean
Returns true if and only if the designated bit is set:
computes ((this & (1 << n)) != 0).
Parameters
| index:int — the index of bit to test.
|
Returns
| Boolean — true if and only if the designated bit is set.
|
Throws
public function toHexString():String
Returns a string representation of this Long as an unsigned integer
in base 16.
Returns
| String — a string representation of this Long as an unsigned integer
in base 16.
|
public function toInt():int
Converts this Long to an int: it is equivalent
to int(this.lowBits) with a possible lose of precision and
a different sign than the original value.
Returns
| int — this Long converted to an int.
|
public function toNumber():Number
Converts this Long to a Number (with a possible
lose of precision).
Returns
| Number — this Long converted to a Number.
|
public function toString(radix:int = 10):String
Returns a string representation of this Long as signed integer
in the specified radix.
Parameters
| radix:int (default = 10) — the radix to be used (2 <= radix <= 36).
|
Returns
| String — a string representation of this Long as signed integer
in the specified radix.
|
Throws
public function xor(b:*):Long
Returns (this ^ b) (bitwise XOR).
Parameters
| b:* — the other operand used in the operation (may be of any type
accepted by the Long constructor).
|
Returns
public static const MAX_VALUE:Long
public static const MIN_VALUE:Long
public static const ONE:Long
The Long constant one.
public static const TEN:Long
The Long constant ten.
public static const ZERO:Long
The Long constant zero.