Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(base.math): extended NumberUtils
- Loading branch information
1 parent
ae3cff5
commit ae39662
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/main/java/org/auioc/mcmod/arnicalib/base/math/NumberUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.auioc.mcmod.arnicalib.base.math; | ||
|
||
public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils { | ||
|
||
public static String toBinaryString(int i, int s) { | ||
return String.format("0b%" + s + "s", Integer.toBinaryString(i)).replace(" ", "0"); | ||
} | ||
|
||
public static String toOctalString(int i, int s) { | ||
return String.format("0o%" + s + "s", Integer.toOctalString(i)).replace(" ", "0"); | ||
} | ||
|
||
public static String toHexString(int i, int s) { | ||
return String.format("0x%" + s + "s", Integer.toHexString(i)).replace(" ", "0"); | ||
} | ||
|
||
public static String toBinaryString(long i, int s) { | ||
return String.format("0b%" + s + "s", Long.toBinaryString(i)).replace(" ", "0"); | ||
} | ||
|
||
public static String toOctalString(long i, int s) { | ||
return String.format("0o%" + s + "s", Long.toOctalString(i)).replace(" ", "0"); | ||
} | ||
|
||
public static String toHexString(long i, int s) { | ||
return String.format("0x%" + s + "s", Long.toHexString(i)).replace(" ", "0"); | ||
} | ||
|
||
} |