Java Integer to intToScaleString(final int number, final int scale)

Here you can find the source of intToScaleString(final int number, final int scale)

Description

int to scale string

License

Apache License

Parameter

Parameter Description
number a parameter
scale a parameter

Return

String

Declaration

@Deprecated
private static String intToScaleString(final int number, final int scale) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static final char[] characters = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
            'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y',
            'z' };

    /**/*from   www  .j a v a2 s . c om*/
     * int to scale string
     * 
     * @param number
     * @param scale
     * @return String
     */
    @Deprecated
    private static String intToScaleString(final int number, final int scale) {
        if (number < 0) {
            throw new RuntimeException(String.format("unsupport nagative number:%s", number));
        }
        int length = scale <= characters.length ? scale : characters.length;
        StringBuilder builder = new StringBuilder();
        int num = number;
        do {
            int mod = num % length;
            builder.append(characters[mod]);
            num = (num - mod) / (length);
        } while (num > 0);
        return builder.reverse().toString();
    }
}

Related

  1. intToRGB(int color)
  2. IntToRGB(int rgbInt)
  3. intToRgbComponents(int rgb)
  4. intToRoman(int i)
  5. intToRoman(int value)
  6. intToShort(final int value)
  7. intToSlider(final int min, final int max, final int value)
  8. intToSortableBytes(int value, byte[] result, int offset)
  9. intToStringBuffer(final int param, final int len)