Erstellt von: Peter Riedel
Schwierigkeitsgrad: fortgeschritten
Modell: Voyage 200
Entwicklungsstand: noch in Arbeit (TODO: Umrechnung negativ dec)

Umrechnung von Dezimalzahl in Hexadezimalzahl mit Vor- und Nachkommastelle(n)

 :dectohex(dec)  :Prgm  :ClrIO  :setMode("Base","Dec")→base  :Local hex,hexa  :""→hex  :© Nachkommastelle(n)  :If mod(dec,1)≠0 Then  : © Local ...  : mod(dec,1)→rest  : rest→list[1]  : 2→i  : Loop  : rest*16→hexa  : mod(hexa,1)→rest  : rest→list[i]  : If int(hexa)≤9 Then  : hex&string(int(hexa))→hex  : ElseIf int(hexa)=10 Then  : hex&"A"→hex  : ElseIf int(hexa)=11 Then  : hex&"B"→hex  : ElseIf int(hexa)=12 Then  : hex&"C"→hex  : ElseIf int(hexa)=13 Then  : hex&"D"→hex  : ElseIf int(hexa)=14 Then  : hex&"E"→hex  : Else  : hex&"F"→hex  : EndIf  : 0→k  : For j,1,i,1  : If list[j]=rest Then  : k+1→k  : If k=1 Then  : j→periodic  : Else  : Exit  : EndIf  : EndIf  : EndFor  : If k=2 Then  : ","&left(hex,periodic-1)&"~"&mid(hex,periodic,j-periodic)→hex  : Exit  : EndIf  : If mod(hexa,1)=0 Then  : ","&hex→hex  : Exit  : EndIf  : i+1→i  : EndLoop  : int(dec)→dec  :EndIf  :© Vorkommastelle(n)  :Loop  : mod(dec,16)→hexa  : If hexa≤9 Then  : string(hexa)&hex→hex  : ElseIf hexa=10 Then  : "A"&hex→hex  : ElseIf hexa=11 Then  : "B"&hex→hex  : ElseIf hexa=12 Then  : "C"&hex→hex  : ElseIf hexa=13 Then  : "D"&hex→hex  : ElseIf hexa=14 Then  : "E"&hex→hex  : Else  : "F"&hex→hex  : EndIf  : int(dec/16)→dec  : If dec=0  : Exit  :EndLoop  :© negativ?  :© Ausgabe  :Disp hex  :setMode("Base",base)  :EndPrgm

Umrechnung von Hexadezimalzahl in Dezimalzahl mit Vor- und Nachkommastelle(n)

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.