{"id":2541,"date":"2025-11-09T14:02:27","date_gmt":"2025-11-09T05:02:27","guid":{"rendered":"https:\/\/www.earce.biz\/?page_id=2541"},"modified":"2025-11-09T14:57:29","modified_gmt":"2025-11-09T05:57:29","slug":"tool-change-radix","status":"publish","type":"page","link":"https:\/\/www.earce.biz\/?page_id=2541","title":{"rendered":"[Tool] Change Radix"},"content":{"rendered":"\n<p class=\"has-text-align-center\" style=\"font-size:12px;white-space:nowrap;\">&lt;&lt; This service is not communicating with the server. &gt;&gt;<\/p>\n\n\n\n<script src=\"\/\/cdnjs.cloudflare.com\/ajax\/libs\/jquery-csv\/0.8.9\/jquery.csv.min.js\"><\/script>\n<script type=\"text\/javascript\">\njQuery().ready(function($){\n\n$(function(){\n\tsessionStorage.clear();\n\t$(\"#textbox1\").on('input', function(e){\n\t\tvar baseval = $(\"#textbox1\").val();\n\t\tvar result = convertAnyToResult(baseval);\n\t\t$(\"#textbox2\").val(result.octal);\n\t\t$(\"#textbox3\").val(result.decimal);\n\t\t$(\"#textbox4\").val(result.hex);\n\t});\n\t$(\"#textbox2\").on('input', function(e){\n\t\tvar baseval = $(\"#textbox2\").val();\n\t\tvar result = convertAnyToResult(baseval);\n\t\t$(\"#textbox1\").val(result.binary);\n\t\t$(\"#textbox3\").val(result.decimal);\n\t\t$(\"#textbox4\").val(result.hex);\n\t});\n\t$(\"#textbox3\").on('input', function(e){\n\t\tvar baseval = $(\"#textbox3\").val();\n\t\tvar result = convertAnyToResult(baseval);\n\t\t$(\"#textbox1\").val(result.binary);\n\t\t$(\"#textbox2\").val(result.octal);\n\t\t$(\"#textbox4\").val(result.hex);\n\t});\n\t$(\"#textbox4\").on('input', function(e){\n\t\tvar baseval = $(\"#textbox4\").val();\n\t\tvar result = convertAnyToResult(baseval);\n\t\t$(\"#textbox1\").val(result.binary);\n\t\t$(\"#textbox2\").val(result.octal);\n\t\t$(\"#textbox3\").val(result.decimal);\n\t});\n\n});\n\n});\n\n\nvar convertAnyToResult = (inputStr) => {\n  if (inputStr.trim()==\"\") {\n    return {\n      binary: \"\",\n      octal: \"\",\n      decimal: \"\",\n      hex: \"\"\n    };\n  }\n  let base = null;\n  let decimal = null;\n\n  \/\/ \u9032\u6570\u5224\u5b9a\n  if (\/^[01]+$\/.test(inputStr)) {\n    base = 2;\n  } else if (\/^[0-7]+$\/.test(inputStr)) {\n    base = 8;\n  } else if (\/^\\d+$\/.test(inputStr)) {\n    base = 10;\n  } else if (\/^[0-9A-Fa-f]+$\/.test(inputStr)) {\n    base = 16;\n  } else {\n    return {\n      binary: \"Invalid number.\",\n      octal: \"Invalid number.\",\n      decimal: \"Invalid number.\",\n      hex: \"Invalid number.\"\n    };\n  }\n\n  \/\/ 10\u9032\u6570\u306b\u5909\u63db\n  decimal = parseInt(inputStr, base);\n\n  return {\n    binary: decimal.toString(2),\n    octal: decimal.toString(8),\n    decimal: decimal.toString(10),\n    hex: decimal.toString(16).toUpperCase()\n  };\n};\n\n<\/script>\n\n\n\n<table>\n<tr>\n<td>Binary<\/td>\n<td>\n  <span style=\"display: inline-flex; align-items: center; gap: 4px;\">\n    <span style=\"width:2em;text-align:right:\">0b<\/span>\n    <input id=\"textbox1\" type=\"text\" placeholder=\"10101010\">\n  <\/span>\n<\/td>\n<\/tr>\n<tr>\n<td>Octal<\/td>\n<td>\n  <span style=\"display: inline-flex; align-items: center; gap: 4px;\">\n    <span style=\"width:2em;text-align:right:\">0o<\/span>\n    <input id=\"textbox2\" type=\"text\" placeholder=\"252\">\n  <\/span>\n<\/td>\n<\/tr>\n<tr>\n<td>Decimal<\/td>\n<td>\n  <span style=\"display: inline-flex; align-items: center; gap: 4px;\">\n    <span style=\"width:2em;text-align:right:\">&nbsp;<\/span>\n    <input id=\"textbox3\" type=\"text\" placeholder=\"170\">\n  <\/span>\n<\/td>\n<\/tr>\n<tr>\n<td>Hexadecimal<\/td>\n<td>\n  <span style=\"display: inline-flex; align-items: center; gap: 4px;\">\n    <span style=\"width:2em;text-align:right:\">0x<\/span>\n    <input id=\"textbox4\" type=\"text\" placeholder=\"AA\">\n  <\/span>\n<\/td>\n<\/tr>\n<\/table>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Binary 0b Octal 0o Decimal &nbsp; Hexadecimal 0x<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":35,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2541","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/2541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2541"}],"version-history":[{"count":38,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/2541\/revisions"}],"predecessor-version":[{"id":2580,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/2541\/revisions\/2580"}],"up":[{"embeddable":true,"href":"https:\/\/www.earce.biz\/index.php?rest_route=\/wp\/v2\/pages\/35"}],"wp:attachment":[{"href":"https:\/\/www.earce.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}