{"id":959,"date":"2020-05-13T10:22:32","date_gmt":"2020-05-13T10:22:32","guid":{"rendered":"https:\/\/computerscienced.co.uk\/site\/?page_id=959"},"modified":"2022-12-30T16:15:12","modified_gmt":"2022-12-30T16:15:12","slug":"hexadecimal-to-denary","status":"publish","type":"page","link":"https:\/\/computerscienced.co.uk\/site\/hexadecimal-conversion\/hexadecimal-to-denary\/","title":{"rendered":"1 digit Hexadecimal to denary"},"content":{"rendered":"\n<body onload=\"displaybinary()\">\n<style>\n#myDIV {\n  width: 100%;\n  padding: 5px 0;\n  text-align: left;\n  background-color: green;\n  color: white;\n  margin-top: 5px;\ndisplay: none;\n}\n#myDIVwrong {\n  width: 100%;\n  padding: 5px 0;\n  text-align: left;\n  background-color: red;\n  color: white;\n  margin-top: 5px;\ndisplay: none;\n}\n#myDIVhelp {\n  width: 100%;\n  padding: 5px 0;\n  text-align: left;\n  background-color: #0073aa;\n  color: white;\n  margin-top: 5px;\ndisplay: none;\n}\n<\/style>\n<script>\nfunction myFunction() {\nvar userInput1 = document.getElementById(\"textInput1\").value;\nvar x = document.getElementById(\"myDIV\");\nvar y = document.getElementById(\"myDIVwrong\"); \nvar nanswer = 0;\nif (w == \"A\"){\n    var nanswer = 10;\n}\n    else if (w == \"B\"){\n       var nanswer = 11; \n    }\n    else if (w == \"C\"){\n        var nanswer = 12;\n    }\n    else if (w == \"D\"){\n        var nanswer = 13;\n    }\n    else if (w == \"E\"){\n        var nanswer = 14;\n    }\n    else if (w == \"F\"){\n        var nanswer = 15\n    }\n    else{\n        var nanswer = w;\n    }\nanswer(nanswer)\nif (userInput1 == nanswer) {\n    x.style.display = \"block\";\n    y.style.display = \"none\";\n  } else {\n    x.style.display = \"none\";  \n    y.style.display = \"block\";\n  }\n    \nreturn nanswer;\n}\nfunction displaybinary() {\nvar x = document.getElementById(\"myDIV\");\n    x.style.display = \"none\";\nvar y = document.getElementById(\"myDIVwrong\");\n    y.style.display = \"none\";\nvar z = document.getElementById(\"myDIVhelp\");\n    z.style.display = \"none\";\nvar hex     = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"]\nvar rannum = Math.floor(Math.random() * hex.length);\nw = hex[rannum];\ndocument.getElementById(\"myText\").innerHTML = w;\n}\n    \nfunction answer(nanswer) {\ndocument.getElementById(\"answerdisplay\").innerHTML = nanswer;\ndocument.getElementById(\"answer2display\").innerHTML = nanswer;\n}\nfunction help() {\nvar z = document.getElementById(\"myDIVhelp\");\n  if (z.style.display === \"block\") {\n    z.style.display = \"none\";\n  } else {\n    z.style.display = \"block\";\n  }\n}\nfunction moveOnMax(field,nextFieldID){\n  if(field.value.length >= field.maxLength){\n    document.getElementById(nextFieldID).focus();\n  }\n}\n<\/script>\n    \n<div id=\"myDIVhelp\" onclick=\"help()\">\n<h2>How do I convert hexadecimal to denary?<\/h2>\n<p>Hexadecimal is a base 16 number.  This means that it contains 16 numbers in each column instead of 10 like in the decimal number system.<\/p>\n    <p>Instead of writing 10 &#8211; 15 in the units column (0-15 is 16 numbers) hexadecimal substitutes letters from 10 to 15.<\/p>\n    <p>10 = A<br> 11 = B<br> 12 = C<br> 13 = D<br> 14 = E<br> 15 = F<\/p>\n    <p>For 1 digit hexadecimal numbers 0 to 9 are the same in hexadecimal as they are in decimal \/ denary.<\/p>\n    <p>Numbers 10 to 15 are converted into letters A to F.  <\/p>\n<\/div>\n    \n<p>Convert the following hexadecimal number to denary \/ decimal:<\/p>\n<h2><span id=\"myText\"><\/span><\/h2>\n<p>Enter your answer: <br><input type=\"text\" id=\"textInput1\" onfocus=\"this.value=''\" style=\"width: 70px;\"\/><\/p>\n<button onclick=\"myFunction()\">Submit your answer<\/button>\n<button onclick=\"displaybinary()\">Click to test again<\/button>\n<button onclick=\"help()\">Help<\/button>\n<div id=\"myDIV\">\n<h3>That is right!<\/h3>\n<h4>The right answer is <span id=\"answerdisplay\"><\/span><\/h4>\n<\/div>\n<div id=\"myDIVwrong\">\n<h3>That is not correct<\/h3>\n<h4>The right answer is <span id=\"answer2display\"><\/span><\/h4>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How do I convert hexadecimal to denary? Hexadecimal is a base 16 number. This means that it contains 16 numbers&#8230;<\/p>\n","protected":false},"author":1,"featured_media":2738,"parent":956,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"disable_featured_image":true,"footnotes":""},"class_list":["post-959","page","type-page","status-publish","has-post-thumbnail","hentry"],"blog_post_layout_featured_media_urls":{"thumbnail":["https:\/\/computerscienced.co.uk\/site\/wp-content\/uploads\/2021\/10\/undraw_Source_code_re_wd9m.svg",150,150,true],"full":["https:\/\/computerscienced.co.uk\/site\/wp-content\/uploads\/2021\/10\/undraw_Source_code_re_wd9m.svg",890,611,false]},"categories_names":null,"comments_number":"0","_links":{"self":[{"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/pages\/959","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/comments?post=959"}],"version-history":[{"count":14,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/pages\/959\/revisions"}],"predecessor-version":[{"id":1531,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/pages\/959\/revisions\/1531"}],"up":[{"embeddable":true,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/pages\/956"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/media\/2738"}],"wp:attachment":[{"href":"https:\/\/computerscienced.co.uk\/site\/wp-json\/wp\/v2\/media?parent=959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}