羅馬數字到阿拉伯數字在線轉換工具
阿拉伯數字
關於羅馬數字到阿拉伯數字在線轉換工具:
這個在線羅馬數字到阿拉伯數字轉換工具可幫助您將一個羅馬數字轉換為阿拉伯數字. 輸入羅馬數字, 阿拉伯數字會顯示在結果框中.
羅馬數字系統(Roman Numerals):
羅馬數字用拉丁字母代表數字("I" 代表"1", "V" 代表"5", "X" 代表"10", "L" 代表"50", "C" 代表"100", "D" 代表"500", "M" 代表"1000")
.羅馬數字系統經常用在論文和書籍排序中.

如何進行羅馬數字到阿拉伯數字轉換?
步驟1:按順序記住拉丁字母代表的數值
('I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000)
.步驟2:從左到右,如果拉丁字母出現在比它大的拉丁字母之前,減去這個拉丁字母代表的數值.
例2.1: IV = V − I = 5 − 1 = 4
例2.2: XL = X − L = 50 − 10 = 40
步驟3:其他情況,增加這個拉丁字母代表的數值.
例3.1: XXXV = X + X + X + V = 10 + 10 + 10 + 5 = 35
例3.2: CXXIII = C + X + X + I + I + I = 100 + 10 + 10 + 1 + 1 + 1 = 123
例1:羅馬數字"CXLVI"轉換為阿拉伯數字:
CXLVI = C + XL + V + I = 100 + (500-10) + 5 + 1 = 146
例2:羅馬數字"CDXCIV"轉換為阿拉伯數字:
CDXCIV = CD + XC + IV = (500-100) + (100-10) + (5-1) = 494
羅馬數字到阿拉伯數字轉換錶:
羅馬數字 | 阿拉伯數字 | 羅馬數字 | 阿拉伯數字 |
---|---|---|---|
I | 1 | XXI | 21 |
II | 2 | XXII | 22 |
III | 3 | XXIII | 23 |
IV | 4 | XXIV | 24 |
V | 5 | XXV | 25 |
VI | 6 | XXVI | 26 |
VII | 7 | XXVII | 27 |
VIII | 8 | XXVIII | 28 |
IX | 9 | XXIX | 29 |
X | 10 | XXX | 30 |
XI | 11 | XXXI | 31 |
XII | 12 | XXXII | 32 |
XIII | 13 | XXXIII | 33 |
XIV | 14 | XXXIV | 34 |
XV | 15 | XXXV | 35 |
XVI | 16 | XXXVI | 36 |
XVII | 17 | XXXVII | 37 |
XVIII | 18 | XXXVIII | 38 |
XIX | 19 | XXXIX | 39 |
XX | 20 | XL | 40 |
鏈接:
維基百科(羅馬數字系統): https://en.wikipedia.org/wiki/Roman_numerals
用Python進行羅馬數字到阿拉伯數字轉換:
- def transform_roman_numeral_to_number(roman_numeral):
- roman_char_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
- res = 0
- for i in range(0, len(roman_numeral)):
- if i == 0 or roman_char_dict[roman_numeral[i]] <= roman_char_dict[roman_numeral[i - 1]]:
- res += roman_char_dict[roman_numeral[i]]
- else:
- res += roman_char_dict[roman_numeral[i]] - 2 * roman_char_dict[roman_numeral[i - 1]]
- return res
- roman_numeral_input = 'MMXVIII'
- number_output = transform_roman_numeral_to_number(roman_numeral_input)
- print('Roman numeral {0} equal to:{1}'.format(roman_numeral_input, number_output))
- -------------------
- Roman numeral MMXVIII equal to:2018
用Java進行羅馬數字到阿拉伯數字轉換:
- import java.util.Map;
- import java.util.HashMap;
- public class NumberConvertManager {
- public static int transform_roman_numeral_to_number(String roman_numeral) {
- Map<Character, Integer> roman_char_dict = new HashMap<Character, Integer>();
- roman_char_dict.put('I', 1);
- roman_char_dict.put('V', 5);
- roman_char_dict.put('X', 10);
- roman_char_dict.put('L', 50);
- roman_char_dict.put('C', 100);
- roman_char_dict.put('D', 500);
- roman_char_dict.put('M', 1000);
- int res = 0;
- for (int i = 0; i < roman_numeral.length(); i += 1) {
- if (i == 0 || roman_char_dict.get(roman_numeral.charAt(i)) <= roman_char_dict.get(roman_numeral.charAt(i - 1)))
- res += roman_char_dict.get(roman_numeral.charAt(i));
- else
- res += roman_char_dict.get(roman_numeral.charAt(i)) - 2 * roman_char_dict.get(roman_numeral.charAt(i - 1));
- }
- return res;
- }
- public static void main(String[] args) {
- String roman_numeral_input = "MMXVIII";
- int number_output = transform_roman_numeral_to_number(roman_numeral_input);
- System.out.println("Roman numeral " + roman_numeral_input + " equal to:" + number_output);
- }
- }
- -------------------
- Roman numeral MMXVIII equal to:2018
相關工具
16進製到10進制轉換
10進製到16進制轉換
8進製到10進制轉換
10進製到8進制轉換
2進製到10進制轉換
10進製到2進制轉換
2進製到16進制轉換
16進製到2進制轉換
ASCII查詢表
16進製到ASCII字符串轉換
ASCII字符串到16進制轉換
2進製到ASCII字符串轉換
ASCII字符串到2進制轉具
分數到小數轉換
小數到分數轉換
百分比到小數轉換
小數到百分比轉換
百分比到分數轉換
分數到百分比轉換
Hex顏色到RGB顏色轉換
RGB顏色到Hex顏色轉換
Hex顏色到RGBA顏色轉換
RGBA顏色轉Hex顏色轉換
羅馬數字對照表1-1000
羅馬數字到阿拉伯數字轉換
阿拉伯數字到羅馬數字轉換