long
in an object.
An object of type Long
contains a single field whose type is long
.
In addition, this class provides several methods for converting a long
to a String
and a String
to a long
, as well as other constants and methods useful when dealing with a long
.
Public Member Functions | |
Long (jlong _value=0) | |
Constructs a newly allocated Long object that represents the primitive long argument. | |
operator jlong & () | |
virtual jbyte | byteValue () const |
Returns the value of this Long as a byte. | |
virtual jshort | shortValue () const |
Returns the value of this Long as a short. | |
virtual jint | intValue () const |
Returns the value of this Long as an int. | |
virtual jlong | longValue () const |
Returns the value of this Long as a long . | |
virtual jfloat | floatValue () const |
Returns the value of this Long as a float . | |
virtual jdouble | doubleValue () const |
Returns the value of this Long as a double . | |
virtual jboolean | equals (const Object &src) const |
Compares this object against the specified object. | |
virtual jint | hashCode () const |
Computes a hashcode for this Long. | |
virtual jint | compareTo (const Object &src) const |
Compares this Long to another Object. | |
virtual String | toString () const |
Returns a String object representing this Long's value. | |
Static Public Member Functions | |
static String | toString (jlong i, jint radix=10) |
Creates a string representation of the first argument in the radix specified by the second argument. | |
static String | toHexString (jlong i) |
Creates a string representation of the long argument as an unsigned integer in base 16. | |
static String | toOctalString (jlong i) |
Creates a string representation of the long argument as an unsigned integer in base 8. | |
static String | toBinaryString (jlong i) |
Creates a string representation of the long argument as an unsigned integer in base 2. | |
static jlong | parseLong (const String &s, jint radix=10) |
Parses the string argument as a signed long in the radix specified by the second argument. | |
static Long | valueOf (const String &s, jint radix=10) |
Returns a new long object initialized to the value of the specified String. | |
Static Public Attributes | |
static const jlong | MIN_VALUE |
The smallest value of type long . | |
static const jlong | MAX_VALUE |
The largest value of type long . |
java::lang::Long::Long | ( | jlong | _value = 0 |
) |
Creates a string representation of the first argument in the radix specified by the second argument.
If the radix is smaller than Character.MIN_RADIX
or larger than Character.MAX_RADIX
, then the radix 10
is used instead.
If the first argument is negative, the first element of the result is the ASCII minus sign '-'
('\u002d'
. If the first argument is not negative, no sign character appears in the result.
The remaining characters of the result represent the magnitude of the first argument. If the magnitude is zero, it is represented by a single zero character '0'
('\u0030'
); otherwise, the first character of the representation of the magnitude will not be the zero character. The following ASCII characters are used as digits: <blockquote>
0123456789abcdefghijklmnopqrstuvwxyz</blockquote> These are
'\u0030'
through '\u0039'
and '\u0061'
through '\u007a'
. If the radix is N, then the first N of these characters are used as radix-N digits in the order shown. Thus, the digits for hexadecimal (radix 16) are 0123456789abcdef
. If uppercase letters are desired, the java.lang.String#toUpperCase() method may be called on the result: <blockquote>Long.toString(n, 16).toUpperCase()</blockquote>
i | a long. | |
radix | the radix. |
Creates a string representation of the long argument as an unsigned integer in base 16.
The unsigned long value is the argument plus 2^{64} if the argument is negative; otherwise, it is equal to the argument.
If the unsigned magnitude is zero, it is represented by a single zero character '0'
('\u0030'
); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as hexadecimal digits: <blockquote>
0123456789abcdef</blockquote> These are the characters
'\u0030'
through '\u0039'
and '\u0061' through '\u0066'
. If uppercase letters are desired, the java.lang.String#toUpperCase() method may be called on the result: <blockquote>Long.toHexString(n).toUpperCase()</blockquote>
i | a long . |
Creates a string representation of the long argument as an unsigned integer in base 8.
The unsigned long value is the argument plus 2^{64} if the argument is negative; otherwise, it is equal to the argument.
If the unsigned magnitude is zero, it is represented by a single zero character '0'
('\u0030'
); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The following characters are used as octal digits: <blockquote>
01234567</blockquote> These are the characters
'\u0030'
through '\u0037'
.
i | a long . |
Creates a string representation of the long argument as an unsigned integer in base 2.
The unsigned long value is the argument plus 2^{64} if the argument is negative; otherwise, it is equal to the argument.
If the unsigned magnitude is zero, it is represented by a single zero character '0'
('&392;u0030'
); otherwise, the first character of the representation of the unsigned magnitude will not be the zero character. The characters '0'
('\u0030'
) and '1'
('\u0031'
) are used as binary digits.
i | a long. |
Parses the string argument as a signed long
in the radix specified by the second argument.
The characters in the string must all be digits of the specified radix (as determined by whether Character.digit
returns a nonnegative value), except that the first character may be an ASCII minus sign '-'
('\u002d'
to indicate a negative value. The resulting long
value is returned.
Note that neither L
nor l
is permitted to appear at the end of the string as a type indicator, as would be permitted in Java programming language source code - except that either L
or l
may appear as a digit for a radix greater than 22.
An exception of type NumberFormatException
is thrown if any of the following situations occurs:
null
or is a string of length zero. radix
is either smaller than java.lang.Character#MIN_RADIX or larger than java.lang.Character#MAX_RADIX. radix
and is not a minus sign '-'
('\u002d'
). radix
. long
. Examples: <blockquote>
parseLong("0", 10) returns 0L parseLong("473", 10) returns 473L parseLong("-0", 10) returns 0L parseLong("-FF", 16) returns -255L parseLong("1100110", 2) returns 102L parseLong("99", 8) throws a NumberFormatException parseLong("Hazelnut", 10) throws a NumberFormatException parseLong("Hazelnut", 36) returns 1356099454469L</blockquote>
s | the String containing the long . | |
radix | the radix to be used. |
long
represented by the string argument in the specified radix. NumberFormatException | if the string does not contain a parsable integer. |
Returns a new long object initialized to the value of the specified String.
Throws an exception if the String cannot be parsed as a long.
The first argument is interpreted as representing a signed integer in the radix specified by the second argument, exactly as if the arguments were given to the parseLong(java.lang.String, int) method that takes two arguments. The result is a Long
object that represents the integer value specified by the string.
In other words, this method returns a Long
object equal to the value of: <blockquote>
new Long(Long.parseLong(s, radix))</blockquote>
s | the String containing the long . | |
radix | the radix to be used. |
Long
initialized to the value represented by the string argument in the specified radix. NumberFormatException | If the String does not contain a parsable long . |
java::lang::Long::operator jlong & | ( | ) |
virtual jbyte java::lang::Long::byteValue | ( | ) | const [virtual] |
virtual jshort java::lang::Long::shortValue | ( | ) | const [virtual] |
virtual jint java::lang::Long::intValue | ( | ) | const [virtual] |
Returns the value of this Long as an int.
int
value represented by this object. Implements java::lang::Number.
virtual jlong java::lang::Long::longValue | ( | ) | const [virtual] |
Returns the value of this Long as a long
.
long
value represented by this object that is converted to type long
and the result of the conversion is returned. Implements java::lang::Number.
virtual jfloat java::lang::Long::floatValue | ( | ) | const [virtual] |
Returns the value of this Long as a float
.
long
value represented by this object is converted to type float
and the result of the conversion is returned. Implements java::lang::Number.
virtual jdouble java::lang::Long::doubleValue | ( | ) | const [virtual] |
Returns the value of this Long as a double
.
long
value represented by this object is converted to type double
and the result of the conversion is returned. Implements java::lang::Number.
Compares this object against the specified object.
The result is true
if and only if the argument is not null
and is a Long
object that contains the same long
value as this object.
obj | the object to compare with. |
true
if the objects are the same; false
otherwise. Reimplemented from java::lang::Object.
virtual jint java::lang::Long::hashCode | ( | ) | const [virtual] |
Computes a hashcode for this Long.
The result is the exclusive OR of the two halves of the primitive long
value represented by this Long
object. That is, the hashcode is the value of the expression: <blockquote>
(int)(this.longValue()^(this.longValue()>>>32))</blockquote>
Reimplemented from java::lang::Object.
Compares this Long to another Object.
If the Object is a Long, this function behaves like compareTo(Long)
. Otherwise, it throws a ClassCastException
(as Longs are comparable only to other Longs).
o | the Object to be compared. |
0
if the argument is a Long numerically equal to this Long; a value less than 0
if the argument is a Long numerically greater than this Long; and a value greater than 0
if the argument is a Long numerically less than this Long. <code>ClassCastException</code> | if the argument is not a Long . |
Reimplemented from java::lang::Comparable.
virtual String java::lang::Long::toString | ( | ) | const [virtual] |
Returns a String object representing this Long's value.
The long integer value represented by this Long object is converted to signed decimal representation and returned as a string, exactly as if the long value were given as an argument to the toString(long) method that takes one argument.
Reimplemented from java::lang::Object.
const jlong java::lang::Long::MIN_VALUE [static] |
The smallest value of type long
.
const jlong java::lang::Long::MAX_VALUE [static] |
The largest value of type long
.