add IIII decimal variation
This commit is contained in:
parent
60545ee3ed
commit
a91a41f28c
52
index.html
52
index.html
|
@ -137,7 +137,8 @@ function r2a(roma, type) {
|
||||||
else arab = arab - prev * 2 + curr;
|
else arab = arab - prev * 2 + curr;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "r10": if (roma == a2r10(arab))
|
case "r10":
|
||||||
|
if (roma == a2r10(arab) || roma == a2r10i(arab))
|
||||||
return arab;
|
return arab;
|
||||||
case "r8": if (roma == a2r8(arab))
|
case "r8": if (roma == a2r8(arab))
|
||||||
return arab;
|
return arab;
|
||||||
|
@ -189,6 +190,18 @@ function a2r10(n) {
|
||||||
return roman;
|
return roman;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function a2r10i(n) {
|
||||||
|
var roman = '';
|
||||||
|
roman += 'M'.repeat(n / 1000); n %= 1000;
|
||||||
|
roman += 'D'.repeat(n / 500); n %= 500;
|
||||||
|
roman += 'C'.repeat(n / 100); n %= 100;
|
||||||
|
roman += 'L'.repeat(n / 50); n %= 50;
|
||||||
|
roman += 'X'.repeat(n / 10); n %= 10;
|
||||||
|
roman += 'V'.repeat(n / 5); n %= 5;
|
||||||
|
roman += 'I'.repeat(n);
|
||||||
|
return roman;
|
||||||
|
}
|
||||||
|
|
||||||
function a2r8(n) {
|
function a2r8(n) {
|
||||||
var roman = '';
|
var roman = '';
|
||||||
roman += 'M'.repeat(n / 512); n %= 512;
|
roman += 'M'.repeat(n / 512); n %= 512;
|
||||||
|
@ -205,14 +218,19 @@ function a2r(arab, type) {
|
||||||
if (arab > 0 && arab < 4000) {
|
if (arab > 0 && arab < 4000) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "r10": return a2r10(arab);
|
case "r10": return a2r10(arab);
|
||||||
|
case "r10i": return a2r10i(arab);
|
||||||
case "r8": return a2r8(arab);
|
case "r8": return a2r8(arab);
|
||||||
}
|
}
|
||||||
} else return "...";
|
} else return "...";
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatea2r() {
|
function updatea2r() {
|
||||||
document.getElementById("outr10").innerHTML =
|
var r10 = a2r(document.getElementById("arin").value, "r10");
|
||||||
a2r(document.getElementById("arin").value, "r10");
|
var r10i = a2r(document.getElementById("arin").value, "r10i");
|
||||||
|
var resr10 = r10;
|
||||||
|
if (r10 != r10i) resr10 += "<br><font style='color: gray;'>" + r10i +
|
||||||
|
"</font>";
|
||||||
|
document.getElementById("outr10").innerHTML = resr10;
|
||||||
document.getElementById("outr8").innerHTML =
|
document.getElementById("outr8").innerHTML =
|
||||||
a2r(document.getElementById("arin").value, "r8");
|
a2r(document.getElementById("arin").value, "r8");
|
||||||
}
|
}
|
||||||
|
@ -257,41 +275,47 @@ function fulltable(type) {
|
||||||
restab += "<tr><td align=right>" + a2r8(num) + "</td>";
|
restab += "<tr><td align=right>" + a2r8(num) + "</td>";
|
||||||
restab += "<td align=center style='background: #112222;'>" + num +
|
restab += "<td align=center style='background: #112222;'>" + num +
|
||||||
"</td>";
|
"</td>";
|
||||||
restab += "<td align=left>" + a2r10(num) + "</td></tr>";
|
var r10 = a2r10(num);
|
||||||
|
var r10i = a2r10i(num);
|
||||||
|
restab += "<td align=left>" + r10;
|
||||||
|
if (r10 != r10i)
|
||||||
|
restab += "<font style='color: gray;'> " + r10i + "</font>";
|
||||||
|
restab += "</td></tr>";
|
||||||
}
|
}
|
||||||
restab += "</table>";
|
restab += "</table>";
|
||||||
document.getElementById("allnum").innerHTML = restab;
|
document.getElementById("allnum").innerHTML = restab;
|
||||||
break;
|
break;
|
||||||
case "roman8":
|
case "roman8":
|
||||||
var restab = "<p align=center>octal coincidence table</p>";
|
var restab = "<p align=center>octal coincidence table</p>";
|
||||||
document.getElementById("allnum").innerHTML = restab;
|
|
||||||
restab += "<table class='allnumtab'><tr><td align=right>arabic" +
|
restab += "<table class='allnumtab'><tr><td align=right>arabic" +
|
||||||
"</td><td align=center>octal roman</td><td align=left>" +
|
"</td><td align=center>octal roman</td><td align=left>" +
|
||||||
"decimal roman value</td>";
|
"decimal roman value</td>";
|
||||||
var num;
|
var num;
|
||||||
for (num = 1; num < 4000; num++) {
|
for (num = 1; num < 4000; num++) {
|
||||||
var a2r8num = a2r8(num);
|
var r8 = a2r8(num);
|
||||||
restab += "<tr><td align=right>" + num + "</td>";
|
restab += "<tr><td align=right>" + num + "</td>";
|
||||||
restab += "<td align=center style='background: #112222;'>" +
|
restab += "<td align=center style='background: #112222;'>" +
|
||||||
a2r8num + "</td>";
|
r8 + "</td>";
|
||||||
restab += "<td align=left>" + r2a(a2r8num, "r10") + "</td></tr>";
|
restab += "<td align=left>" + r2a(r8, "r10") + "</td></tr>";
|
||||||
}
|
}
|
||||||
restab += "</table>";
|
restab += "</table>";
|
||||||
document.getElementById("allnum").innerHTML = restab;
|
document.getElementById("allnum").innerHTML = restab;
|
||||||
break;
|
break;
|
||||||
case "roman10":
|
case "roman10":
|
||||||
var restab = "<p align=center>decimal coincidence table</p>";
|
var restab = "<p align=center>decimal coincidence table</p>";
|
||||||
document.getElementById("allnum").innerHTML = restab;
|
|
||||||
restab += "<table class='allnumtab'><tr><td align=right>arabic" +
|
restab += "<table class='allnumtab'><tr><td align=right>arabic" +
|
||||||
"</td><td align=center>decimal roman</td><td align=left>" +
|
"</td><td align=center>decimal roman</td><td align=left>" +
|
||||||
"octal roman value</td>";
|
"octal roman value</td>";
|
||||||
var num;
|
var num;
|
||||||
for (num = 1; num < 4000; num++) {
|
for (num = 1; num < 4000; num++) {
|
||||||
var a2r10num = a2r10(num);
|
var r10 = a2r10(num);
|
||||||
|
var r10i = a2r10i(num);
|
||||||
restab += "<tr><td align=right>" + num + "</td>";
|
restab += "<tr><td align=right>" + num + "</td>";
|
||||||
restab += "<td align=center style='background: #112222;'>" +
|
restab += "<td align=center style='background: #112222;'>" + r10;
|
||||||
a2r10num + "</td>";
|
if (r10 != r10i)
|
||||||
var coinc = r2a(a2r10num, "r8");
|
restab += "<font style='color: gray;'> " + r10i + "</font>";
|
||||||
|
restab += "</td>";
|
||||||
|
var coinc = r2a(r10, "r8");
|
||||||
if (coinc == "...") restab += "<td></td></tr>";
|
if (coinc == "...") restab += "<td></td></tr>";
|
||||||
else restab += "<td align=left>" + coinc + "</td></tr>";
|
else restab += "<td align=left>" + coinc + "</td></tr>";
|
||||||
}
|
}
|
||||||
|
@ -367,7 +391,7 @@ function chbg() {
|
||||||
<input id="roin" class="inp" onchange="updater2a();"
|
<input id="roin" class="inp" onchange="updater2a();"
|
||||||
size="7" type="text" style="text-transform: uppercase;"
|
size="7" type="text" style="text-transform: uppercase;"
|
||||||
name="roman" maxlength="16" placeholder="MDCLXVI"
|
name="roman" maxlength="16" placeholder="MDCLXVI"
|
||||||
value="V"><br>
|
value="DCLXVI"><br>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Reference in New Issue