Browse files

classpath: j.l.{Integer,Long}.to{Octal,Binary}String

Offer support for toOctalString and toBinaryString in Integer and Long.
  • Loading branch information...
1 parent be952ac commit f8ea506021ac057b0a1b89899e155d5cb9b5ddb2 Pierre Carrier committed Nov 4, 2012
Showing with 12 additions and 0 deletions.
  1. +4 −0 classpath/java/lang/Integer.java
  2. +8 −0 classpath/java/lang/Long.java
View
4 classpath/java/lang/Integer.java
@@ -62,6 +62,10 @@ public static String toHexString(int v) {
return Long.toString(((long) v) & 0xFFFFFFFFL, 16);
}
+ public static String toOctalString(int v) {
+ return Long.toString(((long) v) & 0xFFFFFFFFL, 8);
+ }
+
public static String toBinaryString(int v) {
return Long.toString(((long) v) & 0xFFFFFFFFL, 2);
}
View
8 classpath/java/lang/Long.java
@@ -94,6 +94,14 @@ public static String toHexString(long v) {
return toString(v, 16);
}
+ public static String toOctalString(long v) {
+ return toString(v, 8);
+ }
+
+ public static String toBinaryString(long v) {
+ return toString(v, 2);
+ }
+
public byte byteValue() {
return (byte) value;
}

0 comments on commit f8ea506

Please sign in to comment.