1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
// java.lang.Long
// An implementation of the Java Language Specification section 20.8
// Written by Charles Briscoe-Smith; refer to the file LEGAL for details.
package java.lang;
public final class Long extends Number {
public static final long MIN_VALUE = 0x8000000000000000L;
public static final long MAX_VALUE = 0x7fffffffffffffffL;
private long myvalue;
public Long(long value) {
myvalue=value;
}
// public Long(String s) throws NumberFormatException {
// myvalue=parseLong(s);
// }
public String toString() {
return toString(myvalue);
}
public boolean equals(Object obj) {
try {
return ((Long) obj).myvalue==myvalue;
} catch (NullPointerException e) {
return false;
} catch (ClassCastException e) {
return false;
}
}
public int hashCode() {
return (int)(myvalue^(myvalue>>>32));
}
public int intValue() {
return (int) myvalue;
}
public long longValue() {
return myvalue;
}
public float floatValue() {
return (float) myvalue;
}
public double doubleValue() {
return (double) myvalue;
}
private static String digit="0123456789abcdefghijklmnopqrstuvwxyz";
public static String toString(long l) {
return toString(l, 10);
}
public static String toString(long l, int radix) {
if (radix<Character.MIN_RADIX || radix>Character.MAX_RADIX)
radix=10;
if (l==0) return "0";
if (l<0) return "-"+toString(-l, radix);
if (l<radix) return new Character(digit.charAt((int)l)).toString();
return toString(l/radix, radix)+digit.charAt((int)(l%radix));
}
public static String toHexString(long l) {
if (l>=0 && l<16) return new Character(digit.charAt((int)l)).toString();
return toHexString(l>>>4) + digit.charAt((int)l&15);
}
public static String toOctalString(long l) {
if (l>=0 && l<8) return new Character(digit.charAt((int)l)).toString();
return toHexString(l>>>3) + digit.charAt((int)l&7);
}
public static String toBinaryString(long l) {
if (l>=0 && l<2) return new Character(digit.charAt((int)l)).toString();
return toHexString(l>>>1) + digit.charAt((int)l&1);
}
// public static long parseLong(String s) throws NumberFormatException;
// public static long parseLong(String s, int radix)
// throws NumberFormatException;
// public static Long valueOf(String s) throws NumberFormatException;
// public static Long valueOf(String s, int radix)
// throws NumberFormatException;
// public static Long getLong(String nm);
// public static Long getLong(String nm, long val);
// public static Long getLong(String nm, Long val);
}
|