Reference:Java.lang.Long
From Triled Wiki
java.lang
public final class java.lang.Long
| java.lang.Object | |||
| java.lang.Number | Serializable | ||
| java.lang.Long | Comparable | ||
Long is the wrapper for the primitive type long.
As with the specification, this implementation relied on code laid out in Henry S. Warren, Jr.'s Hacker's Delight, (Addison Wesley, 2002) as well as The Aggregate's Magic Algorithms.
See Also
[edit] Summary
[edit] Constants
| Value | ||||
|---|---|---|---|---|
| long | MAX_VALUE |
Constant for the maximum long value, 263-1. | 9223372036854775807 | 0x7fffffffffffffff |
| long | MIN_VALUE |
Constant for the minimum long value, -231. | -9223372036854775808 | 0x8000000000000000 |
| int | SIZE |
Constant for the number of bits to represent a long in two's compliment form. | 64 | 0x00000040 |
| Class | TYPE | The java.lang.Class that represents this class. |
[edit] Public Constructors
| Long (long value) | |||||
| Constructs a new instance of the receiver which represents the long valued argument. | |||||
| Long (String string) | |||||
| Constructs a new instance of this class given a string. | |||||
[edit] Public Methods
| static | int | bitCount (long lng) | |||
|
Counts the number of 1 bits in the long value passed; this is sometimes referred to as a population count. | |||||
| byte | byteValue () | ||||
| Answers the byte value which the receiver represents | |||||
| int | compareTo (Long object) | ||||
|
Compares this Long to the Long passed. | |||||
| static | Long | decode (String string) | |||
| Parses the string argument as if it was a long value and returns the result. | |||||
| double | doubleValue () | ||||
| Answers the double value which the receiver represents | |||||
| boolean | equals (Object o) | ||||
| Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison. | |||||
| float | floatValue () | ||||
| Answers the float value which the receiver represents | |||||
| static | Long | getLong (String string, Long defaultValue) | |||
| Answers an Long representing the long value of the property named by the argument. | |||||
| static | Long | getLong (String string, long defaultValue) | |||
| Answers a Long representing the long value of the property named by the argument. | |||||
| static | Long | getLong (String string) | |||
| Answers a Long representing the long value of the property named by the argument. | |||||
| int | hashCode () | ||||
| Answers an integer hash code for the receiver. | |||||
| static | long | highestOneBit (long lng) | |||
|
Determines the highest (leftmost) bit that is 1 and returns the value that is the bit mask for that bit. | |||||
| int | intValue () | ||||
| Answers the int value which the receiver represents | |||||
| long | longValue () | ||||
| Answers the long value which the receiver represents | |||||
| static | long | lowestOneBit (long lng) | |||
|
Determines the lowest (rightmost) bit that is 1 and returns the value that is the bit mask for that bit. | |||||
| static | int | numberOfLeadingZeros (long lng) | |||
|
Determines the number of leading zeros in the long passed prior to the highest one bit. | |||||
| static | int | numberOfTrailingZeros (long lng) | |||
|
Determines the number of trailing zeros in the long passed after the lowest one bit. | |||||
| static | long | parseLong (String string, int radix) | |||
| Parses the string argument as if it was an long value and returns the result. | |||||
| static | long | parseLong (String string) | |||
| Parses the string argument as if it was a long value and returns the result. | |||||
| static | long | reverse (long lng) | |||
|
Reverses the bytes of a long. | |||||
| static | long | reverseBytes (long lng) | |||
|
Reverses the bytes of a long. | |||||
| static | long | rotateLeft (long lng, int distance) | |||
|
Rotates the bits of lng to the left by the distance bits. | |||||
| static | long | rotateRight (long lng, int distance) | |||
|
Rotates the bits of lng to the right by the distance bits. | |||||
| short | shortValue () | ||||
| Answers the short value which the receiver represents | |||||
| static | int | signum (long lng) | |||
|
The signum function for long values. | |||||
| static | String | toBinaryString (long l) | |||
| Answers a string containing '0' and '1' characters which describe the binary representation of the argument. | |||||
| static | String | toHexString (long l) | |||
| Answers a string containing characters in the range 0..7, a..f which describe the hexadecimal representation of the argument. | |||||
| static | String | toOctalString (long l) | |||
| Answers a string containing characters in the range 0..7 which describe the octal representation of the argument. | |||||
| static | String | toString (long l, int radix) | |||
| Answers a string containing characters in the range 0..9, a..z (depending on the radix) which describe the representation of the argument in that radix. | |||||
| String | toString () | ||||
| Answers a string containing a concise, human-readable description of the receiver. | |||||
| static | String | toString (long l) | |||
| Answers a string containing characters in the range 0..9 which describe the decimal representation of the argument. | |||||
| static | Long | valueOf (String string, int radix) | |||
| Parses the string argument as if it was an long value and returns the result. | |||||
| static | Long | valueOf (String string) | |||
| Parses the string argument as if it was an long value and returns the result. | |||||
| static | Long | valueOf (long lng) | |||
|
Returns a Long instance for the long value passed. | |||||
[edit] Methods inherited from class java.lang.Number
byteValue, doubleValue, floatValue, intValue, longValue, shortValue[edit] Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait[edit] Methods inherited from interface java.lang.Comparable
[edit] Details
[edit] Constants
[edit] public static final long MAX_VALUE
Constant for the maximum long value, 263-1. Constant Value: 9223372036854775807 (0x7fffffffffffffff)
[edit] public static final long MIN_VALUE
Constant for the minimum long value, -231. Constant Value: -9223372036854775808 (0x8000000000000000)
[edit] public static final int SIZE
Constant for the number of bits to represent a long in two's compliment form. Constant Value: 64 (0x00000040)
[edit] public static final Class TYPE
The java.lang.Class that represents this class.
[edit] Public Constructors
[edit] public Long(long value)
Constructs a new instance of the receiver which represents the long valued argument.
Parameters
| value | the long to store in the new instance. |
|---|
[edit] public Long(String string)
Constructs a new instance of this class given a string.
Parameters
| string | a string representation of an long quantity. |
|---|
Throws
| NumberFormatException | if the argument could not be parsed as a long quantity. |
|---|
[edit] Public Methods
[edit] public static int bitCount(long lng)
Counts the number of 1 bits in the long value passed; this is sometimes referred to as a population count.
Parameters
| lng | The long value to process. |
|---|
Returns
- The number of 1 bits.
[edit] public byte byteValue()
Answers the byte value which the receiver represents
Returns
- byte the value of the receiver.
[edit] public int compareTo(Long object)
Compares this Long to the Long passed. If this instance's value is equal to the value of the instance passed, then 0 is returned. If this instance's value is less than the value of the instance passed, then a negative value is returned. If this instance's value is greater than the value of the instance passed, then a positive value is returned.
Parameters
| object | The instance to compare to. |
|---|
Throws
| NullPointerException | if object is null. |
|---|
[edit] public static Long decode(String string)
Parses the string argument as if it was a long value and returns the result. Throws NumberFormatException if the string does not represent a long quantity. The string may be a hexadecimal ("0x..."), octal ("0..."), or decimal ("...") representation of a long.
Parameters
| string | a string representation of an long quantity. |
|---|
Returns
- Long the value represented by the argument
Throws
| NumberFormatException | if the argument could not be parsed as an long quantity. |
|---|
[edit] public double doubleValue()
Answers the double value which the receiver represents
Returns
- double the value of the receiver.
[edit] public boolean equals(Object o)
Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.
In this case, the argument must also be an Long, and the receiver and argument must represent the same long value.
Parameters
| o | the object to compare with this object |
|---|
Returns
- true if the object is the same as this object false if it is different from this object
See Also
[edit] public float floatValue()
Answers the float value which the receiver represents
Returns
- float the value of the receiver.
[edit] public static Long getLong(String string, Long defaultValue)
Answers an Long representing the long value of the property named by the argument. If the property could not be found, or its value could not be parsed as an long, answer the second argument.
Parameters
| string | The name of the desired long property. |
|---|
Returns
- Long An Long representing the value of the property.
[edit] public static Long getLong(String string, long defaultValue)
Answers a Long representing the long value of the property named by the argument. If the property could not be found, or its value could not be parsed as a long, answer a Long representing the second argument.
Parameters
| string | The name of the desired long property. |
|---|
Returns
- Long An Long representing the value of the property.
[edit] public static Long getLong(String string)
Answers a Long representing the long value of the property named by the argument. If the property could not be found, or its value could not be parsed as a long, answer null.
Parameters
| string | The name of the desired integer property. |
|---|
Returns
- Long A Long representing the value of the property.
[edit] public int hashCode()
Answers an integer hash code for the receiver. Any two objects which answer true when passed to equals must answer the same value for this method.
Returns
- the receiver's hash
See Also
[edit] public static long highestOneBit(long lng)
Determines the highest (leftmost) bit that is 1 and returns the value that is the bit mask for that bit. This is sometimes referred to as the Most Significant 1 Bit.
Parameters
| lng | The long to interrogate. |
|---|
Returns
- The bit mask indicating the highest 1 bit.
[edit] public int intValue()
Answers the int value which the receiver represents
Returns
- int the value of the receiver.
[edit] public long longValue()
Answers the long value which the receiver represents
Returns
- long the value of the receiver.
[edit] public static long lowestOneBit(long lng)
Determines the lowest (rightmost) bit that is 1 and returns the value that is the bit mask for that bit. This is sometimes referred to as the Least Significant 1 Bit.
Parameters
| lng | The long to interrogate. |
|---|
Returns
- The bit mask indicating the lowest 1 bit.
[edit] public static int numberOfLeadingZeros(long lng)
Determines the number of leading zeros in the long passed prior to the highest one bit.
Parameters
| lng | The long to process. |
|---|
Returns
- The number of leading zeros.
[edit] public static int numberOfTrailingZeros(long lng)
Determines the number of trailing zeros in the long passed after the lowest one bit.
Parameters
| lng | The long to process. |
|---|
Returns
- The number of trailing zeros.
[edit] public static long parseLong(String string, int radix)
Parses the string argument as if it was an long value and returns the result. Throws NumberFormatException if the string does not represent an long quantity. The second argument specifies the radix to use when parsing the value.
Parameters
| string | a string representation of an long quantity. |
|---|---|
| radix | the base to use for conversion. |
Returns
- long the value represented by the argument
Throws
| NumberFormatException | if the argument could not be parsed as an long quantity. |
|---|
[edit] public static long parseLong(String string)
Parses the string argument as if it was a long value and returns the result. Throws NumberFormatException if the string does not represent a long quantity.
Parameters
| string | a string representation of a long quantity. |
|---|
Returns
- long the value represented by the argument
Throws
| NumberFormatException | if the argument could not be parsed as a long quantity. |
|---|
[edit] public static long reverse(long lng)
Reverses the bytes of a long.
Parameters
| lng | The long to reverse. |
|---|
Returns
- The reversed value.
[edit] public static long reverseBytes(long lng)
Reverses the bytes of a long.
Parameters
| lng | The long to reverse. |
|---|
Returns
- The reversed value.
[edit] public static long rotateLeft(long lng, int distance)
Rotates the bits of lng to the left by the distance bits.
Parameters
| lng | The long value to rotate left. |
|---|---|
| distance | The number of bits to rotate. |
Returns
- The rotated value.
[edit] public static long rotateRight(long lng, int distance)
Rotates the bits of lng to the right by the distance bits.
Parameters
| lng | The long value to rotate right. |
|---|---|
| distance | The number of bits to rotate. |
Returns
- The rotated value.
[edit] public short shortValue()
Answers the short value which the receiver represents
Returns
- short the value of the receiver.
[edit] public static int signum(long lng)
The signum function for long values. This method returns -1 for negative values, 1 for positive values and 0 for the value 0.
Parameters
| lng | The long value. |
|---|
Returns
- -1 if negative, 1 if positive otherwise 0.
[edit] public static String toBinaryString(long l)
Answers a string containing '0' and '1' characters which describe the binary representation of the argument.
Parameters
| l | a long to get the binary representation of |
|---|
Returns
- String the binary representation of the argument
[edit] public static String toHexString(long l)
Answers a string containing characters in the range 0..7, a..f which describe the hexadecimal representation of the argument.
Parameters
| l | a long to get the hex representation of |
|---|
Returns
- String the hex representation of the argument
[edit] public static String toOctalString(long l)
Answers a string containing characters in the range 0..7 which describe the octal representation of the argument.
Parameters
| l | a long to get the octal representation of |
|---|
Returns
- String the octal representation of the argument
[edit] public static String toString(long l, int radix)
Answers a string containing characters in the range 0..9, a..z (depending on the radix) which describe the representation of the argument in that radix.
Parameters
| l | a long to get the representation of |
|---|---|
| radix | the base to use for conversion. |
Returns
- String the representation of the argument
[edit] public String toString()
Answers a string containing a concise, human-readable description of the receiver.
Returns
- a printable representation for the receiver.
[edit] public static String toString(long l)
Answers a string containing characters in the range 0..9 which describe the decimal representation of the argument.
Parameters
| l | a long to get the representation of |
|---|
Returns
- String the representation of the argument
[edit] public static Long valueOf(String string, int radix)
Parses the string argument as if it was an long value and returns the result. Throws NumberFormatException if the string does not represent an long quantity. The second argument specifies the radix to use when parsing the value.
Parameters
| string | a string representation of an long quantity. |
|---|---|
| radix | the base to use for conversion. |
Returns
- Long the value represented by the argument
Throws
| NumberFormatException | if the argument could not be parsed as an long quantity. |
|---|
[edit] public static Long valueOf(String string)
Parses the string argument as if it was an long value and returns the result. Throws NumberFormatException if the string does not represent an long quantity.
Parameters
| string | a string representation of an long quantity. |
|---|
Returns
- Long the value represented by the argument
Throws
| NumberFormatException | if the argument could not be parsed as an long quantity. |
|---|
[edit] public static Long valueOf(long lng)
Returns a Long instance for the long value passed. This method is preferred over the constructor, as this method may maintain a cache of instances.
Parameters
| lng | The long value. |
|---|
Returns
- A Long instance.
[edit] References
- Original documentation page for Android SDK build m5-rc15e - 14 apr 2008 17:27
