package com.skatepark.shoveit.misc;

import java.util.Objects;

public class BasicConverter {

    private static final String TABLE[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};

    public int hex2Dec(String hexadecimal) {
        Objects.requireNonNull(hexadecimal, "hexadecimal should not be null.");

        int result = 0;
        char characters[] = hexadecimal.toCharArray();
        for (int i = 0; i < characters.length; i++) {
            int value = Character.getNumericValue(characters[i]);
            result += value * (Math.pow(16, characters.length - 1 - i));
        }
        return result;
    }

    public String dec2Hex(int decimal) {
        if (decimal < 16) {
            return TABLE[decimal];
        }
        int value = decimal / 16;
        int reminder = decimal % 16;

        return dec2Hex(value) + TABLE[reminder];

//        StringBuilder result = new StringBuilder();
//        while (decimal > 16) {
//            int value = decimal / 16;
//            if (value >= 16){
//                System.out.println(decimal);
//            }
//            result.append(TABLE[value]);
//
//            decimal = decimal % 16;
//        }
//
//        if (decimal < 16) {
//            result.append(TABLE[decimal]);
//        }
//        return result.toString();
    }
}

@@ -836,17 +836,16 @@
 l %25 16;%0A
-%0A
         
@@ -888,453 +888,8 @@
 er%5D;
-%0A%0A//        StringBuilder result = new StringBuilder();%0A//        while (decimal %3E 16) %7B%0A//            int value = decimal / 16;%0A//            if (value %3E= 16)%7B%0A//                System.out.println(decimal);%0A//            %7D%0A//            result.append(TABLE%5Bvalue%5D);%0A//%0A//            decimal = decimal %25 16;%0A//        %7D%0A//%0A//        if (decimal %3C 16) %7B%0A//            result.append(TABLE%5Bdecimal%5D);%0A//        %7D%0A//        return result.toString();
 %0A   

remove javadoc