Java Integer to Hex int2hex(final int i)

Here you can find the source of int2hex(final int i)

Description

Convert an integer into a hex-string.

License

Open Source License

Parameter

Parameter Description
i the integer

Return

the hex-value

Declaration

private static String int2hex(final int i) 

Method Source Code

//package com.java2s;
/**//from ww w . ja v  a 2  s .  c  om
 * This file is part of OSMNavigation by Marcus Wolschon <a href="mailto:Marcus@Wolscon.biz">Marcus@Wolscon.biz</a>.
 * You can purchase support for a sensible hourly rate or
 * a commercial license of this file (unless modified by others) by contacting him directly.
 *
 *  OSMNavigation is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  LibOSM is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with OSMNavigation.  If not, see <http://www.gnu.org/licenses/>.
 *
 ***********************************
 * Editing this file:
 *  -For consistent code-quality this file should be checked with the
 *   checkstyle-ruleset enclosed in this project.
 *  -After the design of this file has settled it should get it's own
 *   JUnit-Test that shall be executed regularly. It is best to write
 *   the test-case BEFORE writing this class and to run it on every build
 *   as a regression-test.
 */

public class Main {
    /**
     * 16.
     */
    private static final int HEX = 16;

    /**
     * Convert an integer into a hex-string.
     * @param i the integer
     * @return the hex-value
     */
    private static String int2hex(final int i) {
        String s = Integer.toHexString(i / HEX) + Integer.toHexString(i % HEX);
        return s.toUpperCase();
    }
}

Related

  1. convertIntArrayToHexString(int[] arr)
  2. convertIntToHex(int i)
  3. convertInttoHexa(int n)
  4. int2CharHex(int integer)
  5. int2hex(final int a, final StringBuffer str)
  6. int2hex(int a, StringBuffer str)
  7. int2hex(int i)
  8. int2hex(int i)
  9. int2HexChar(int val)