Java Hex Calculate toHex(long i)

Here you can find the source of toHex(long i)

Description

to Hex

License

Open Source License

Declaration

public static String toHex(long i) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  w w w . j a  va  2s.  c  o m*/
     * Converts a number to a hex value
     *
     * @param i  The value
     * @param r1 Should the string be fancy? (0xYYYY)
     * @param r0 Length of fancieness
     * @return The string
     */
    public static String toHex(long i, int r0, boolean r1) {
        String h = Long.toHexString(i).toUpperCase();
        while (h.length() < r0 && r1) {
            h = 0 + h;
        }

        return (r1 ? "0x" : "") + h;
    }

    public static String toHex(long i) {
        return toHex(i, 2, false);
    }
}

Related

  1. toHex(int value)
  2. toHex(int value, int bits)
  3. toHex(int value, int length)
  4. toHex(int value, int length)
  5. toHex(int value, int minNumOfDigits)
  6. toHex(long i, int r0, boolean r1)
  7. toHex(long l, int length)
  8. toHex(Long value, int charCount)
  9. toHex(long value, int length)