lsr 1 month ago
parent c49e300f93
commit 9915516d18

@ -0,0 +1,19 @@
<script>
function convert() {
const inputNumber = document.getElementById("inputNumber").value;
const fromBase = parseInt(document.getElementById("fromBase").value);
const toBase = parseInt(document.getElementById("toBase").value);
try {
// 将输入的原进制数转换为10进制
const decimalValue = parseInt(inputNumber, fromBase);
// 将10进制数转换为目标进制
const convertedValue = decimalValue.toString(toBase).toUpperCase();
// 显示结果
document.getElementById("result").innerText = `转换结果 (Y): ${convertedValue}`;
} catch (error) {
document.getElementById("result").innerText = "转换失败,请确保输入正确。";
}
}
</script>
Loading…
Cancel
Save