Java Integer to intToRoman(int value)

Here you can find the source of intToRoman(int value)

Description

int To Roman

License

Open Source License

Declaration

public static String intToRoman(int value) 

Method Source Code

//package com.java2s;

public class Main {
    private final static String[] BASIC_ROMAN_NUMBERS = { "m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix",
            "v", "iv", "i" };
    private final static int[] BASIC_VALUES = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };

    public static String intToRoman(int value) {
        if (value <= 0 && value >= 4000) {
            return null;
        }//  www.  ja v a 2s . co  m

        String romanString = "";

        int remainder = value;
        for (int i = 0; i < BASIC_VALUES.length; i++) {
            while (remainder >= BASIC_VALUES[i]) {
                romanString += BASIC_ROMAN_NUMBERS[i];
                remainder -= BASIC_VALUES[i];
            }
        }
        return romanString;
    }
}

Related

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