The Number System Calculator





The base calculator

This program calculates any number into another number system.

Next to the common number systems like decimal, hexadecimal and binary you can also enter a custom one.




Hexadecimal

Binary

Decimal

Other base between 2 and 36

Number to calculate

import js def umrechnerAndererBasis(self): try: if (js.document.getElementById("basisBox").value) and int(js.document.getElementById("basisBox").value)>=2 and js.document.getElementById("basisBoxZahl").value: neueBasis = True neuerBasisWert = int(js.document.getElementById("basisBox").value) umzurechnendeZahl = js.document.getElementById("basisBoxZahl").value else: neueBasis = False except ValueError: neueBasis = False try: if neueBasis: js.document.getElementById("decBox3").value = int(umzurechnendeZahl, neuerBasisWert) js.document.getElementById("binBox2").value = bin(int(umzurechnendeZahl, neuerBasisWert))[2:] js.document.getElementById("hexBox1").value = hex(int(umzurechnendeZahl, neuerBasisWert))[2:] else: js.document.getElementById("hexBox1").value = "" js.document.getElementById("binBox2").value = "" js.document.getElementById("decBox3").value = "" except ValueError: js.document.getElementById("decBox3").value = "Basis (2-36) und Zahl richtig angeben" js.document.getElementById("binBox2").value = "Basis (2-36) und Zahl richtig angeben" js.document.getElementById("hexBox1").value = "Basis (2-36) und Zahl richtig angeben" def umrechnerAusHex(self): hexCheckBox = js.document.getElementById("hexBox1").value try: if int(hexCheckBox, 16): isHex = True else: isHex = False except ValueError: isHex = False if hexCheckBox and isHex == True: js.document.getElementById("binBox2").value = bin(int(hexCheckBox,16))[2:] js.document.getElementById("decBox3").value = int(hexCheckBox,16) js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = "" else: js.document.getElementById("binBox2").value = "" js.document.getElementById("decBox3").value = "" js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = "" def umrechnerAusBin(self): binCheckBox = js.document.getElementById("binBox2").value try: if int(binCheckBox, 2): isBin = True else: isBin = False except ValueError: isBin = False if binCheckBox and isBin == True: binInDec = int(binCheckBox,2) js.document.getElementById("hexBox1").value = hex(binInDec)[2:] js.document.getElementById("decBox3").value = binInDec js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = "" else: js.document.getElementById("hexBox1").value = "" js.document.getElementById("decBox3").value = "" js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = "" def umrechnerAusDec(self): tempFeld = js.document.getElementById("decBox3").value try: if int(tempFeld): isDec = True else: isDec = False except ValueError: isDec = False if js.document.getElementById("decBox3").value and isDec == True: decCheckBox = int(tempFeld) js.document.getElementById("hexBox1").value = hex(decCheckBox)[2:] js.document.getElementById("binBox2").value = bin(decCheckBox)[2:] js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = "" else: js.document.getElementById("hexBox1").value = "" js.document.getElementById("binBox2").value = "" js.document.getElementById("basisBox").value = "" js.document.getElementById("basisBoxZahl").value = ""

Made with PyScript - Version 1.2.0