Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


how to covert roman number to numeric number

Contributor ,
Dec 09, 2010 Dec 09, 2010

Copy link to clipboard

Copied

hi all

Any idea how to convert roman number(i ii iii......) to numeric number (1 2 3.....)

thank in advance

Mi_D

TOPICS
Scripting

Views

382

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Dec 09, 2010 Dec 09, 2010

Copy link to clipboard

Copied

Hey!

I have exactly what you need: http://bit.ly/bFRuoT

Hope that helps!

--

tomaxxi

http://indisnip.wordpress.com/

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 09, 2010 Dec 09, 2010

Copy link to clipboard

Copied

Hi tomaxxi

Thank its working fine

I_D

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 31, 2021 Jul 31, 2021

Copy link to clipboard

Copied

LATEST

Hi @Marijan_Tompa__tomaxxi_,

Here is the way to convert roman to int and int to roman.

 

 

RomanToInteger('MCMLXXXII');//MCMLXXXII:1982
IntegerToRoman(1982);//1982:MCMLXXXII

function RomanToInteger(str) {
    var map = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000 };
    var result = 0;

    for (var i = 0; i < str.length; i++) {
        if (i && map[str.charAt(i)] > map[str.charAt(i - 1)]) {
            result += (map[str.charAt(i)] - (map[str.charAt(i - 1)] * 2));
        }
        else {
            result += map[str.charAt(i)];
        }
    }
    return result;
}

function IntegerToRoman(num) {
    var units = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'XI'];
    var tens = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'];
    var hundreds = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'];
    var thousands = ['', 'M', 'MM', 'MMM'];

    return thousands[parseInt(num / 1000)] +
        hundreds[parseInt((num % 1000) / 100)] +
        tens[parseInt((num % 100) / 10)] +
        units[num % 10];
}

 

 

-Sumit

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines