| | |
| | | return String.format("%04x", num).toUpperCase(); |
| | | } |
| | | |
| | | // 计算16进制对应的数值 |
| | | public static int GetHex(char ch) throws Exception { |
| | | if (ch >= '0' && ch <= '9') |
| | | return (int) (ch - '0'); |
| | | if (ch >= 'a' && ch <= 'f') |
| | | return (int) (ch - 'a' + 10); |
| | | if (ch >= 'A' && ch <= 'F') |
| | | return (int) (ch - 'A' + 10); |
| | | throw new Exception("error param"); |
| | | } |
| | | |
| | | // 计算幂 |
| | | public static int GetPower(int nValue, int nCount) throws Exception { |
| | | if (nCount < 0) |
| | | throw new Exception("nCount can't small than 1!"); |
| | | if (nCount == 0) |
| | | return 1; |
| | | int nSum = 1; |
| | | for (int i = 0; i < nCount; ++i) { |
| | | nSum = nSum * nValue; |
| | | } |
| | | return nSum; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | |
| | | |
| | | System.out.println(d1 + d2); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |