to beenden1 make "f1? "false windowdelete "f1 end to beenden2 make "f2? "false windowdelete "f2 end to berechnen1 loeschen1_1 make "dezimalzahl deceingabe ifelse not numberp :dezimalzahl~ [comboboxsettext "e1_1 [---> Fehler!]]~ [umwandeln1] end to berechnen2 loeschen2_1 make "hexadezimalzahl hexeingabe ifelse not wordp :hexadezimalzahl~ [comboboxsettext "e2_1 [---> Fehler!]]~ [umwandeln2] end to betrag :zahl ifelse :zahl < 0 [output (-1) * :zahl] [output :zahl] end to bindeczahl :zahl ifelse (ganzanteil :zahl) = 0~ [ifelse (gebranteil :zahl) = 0~ [output "0]~ [output word "0. gebrbin gebranteil :zahl]]~ [ifelse (gebranteil :zahl) = 0~ [output ganzbin ganzanteil :zahl]~ [output (word ganzbin ganzanteil :zahl ". gebrbin gebranteil :zahl)]] end to binexp :wort ifelse not memberp ". :wort~ [output (count :wort) - 1]~ [ifelse (first :wort) = "0~ [output exprechts :wort]~ [output explinks :wort]] end to binhexzahl :wort ifelse emptyp :wort~ [output "]~ [ifelse (first :wort) = ".~ [output word ". (binhexzahl butfirst :wort)]~ [output word (vornullen bindeczahl dechexzahl first :wort 4)~ (binhexzahl butfirst :wort)]] end to binzeichen :zahl output char (48 + :zahl) end to decbinzahl :wort output (vorkommazahl vorkomma :wort 2) + (nachkommazahl nachkomma :wort 2) end to deceingabe ifelse emptyp comboboxgettext "e1_1~ [output [false]]~ [make "zahl first comboboxgettext "e1_1~ ifelse not numberp :zahl~ [output [false]]~ [ifelse and ((betrag :zahl) < 5.87748e-39) (not (:zahl = 0))~ [output [false]]~ [ifelse (betrag :zahl) > 6.80564e+38~ [output [false]]~ [output :zahl]]]] end to decgleit make "f1? "true make "sb1_1? "false make "sb1_2? "false windowcreate "hf "f1 [Umwandlung von Dezimalzahlen in 32-Bit-Gleitkommazahlen] 0 0 320 240 [] staticcreate "f1 "l1_1 [Geben Sie die Dezimalzahl an:] 10 12 115 12 comboboxcreate "f1 "e1_1 120 10 100 12 buttoncreate "f1 "b1_berechnen [Berechnen] 255 10 50 12 [berechnen1] staticcreate "f1 "l1_2 [Ausgabe im Dualsystem:] 10 30 150 12 comboboxcreate "f1 "e1_2 10 40 295 12 staticcreate "f1 "l1_3 [Ausgabe im Hexadezimalsystem:] 10 55 150 12 comboboxcreate "f1 "e1_3 10 65 295 12 staticcreate "f1 "l1_4 [Vorzeichen, dual:] 10 87 115 12 comboboxcreate "f1 "e1_4 120 85 10 12 staticcreate "f1 "l1_5 [---> 1. Bit] 135 87 50 12 staticcreate "f1 "l1_6 [Exponent der Gleitkommazahl:] 10 102 115 12 comboboxcreate "f1 "e1_5 120 100 50 12 staticcreate "f1 "l1_7 [---> Charakter des Exponenten:] 10 117 115 12 comboboxcreate "f1 "e1_6 120 115 100 12 staticcreate "f1 "l1_8 [---> 2. - 9. Bit] 225 117 80 12 staticcreate "f1 "l1_9 [Mantisse der Gleitkommazahl:] 10 135 150 12 comboboxcreate "f1 "e1_7 10 145 210 12 staticcreate "f1 "l1_10 [---> 10. - 32. Bit] 225 147 80 12 staticcreate "f1 "l1_11 [Ausgabe der Gleitkommazahl, dual:] 10 165 150 12 comboboxcreate "f1 "e1_8 10 175 210 12 staticcreate "f1 "l1_12 [---> 32 - Bit - Codierung] 225 177 80 12 staticcreate "f1 "l1_13 [Ausgabe der Gleitkommazahl, hexadezimal:] 10 190 150 12 comboboxcreate "f1 "e1_9 10 200 100 12 buttoncreate "f1 "b1_loeschen [Loeschen] 255 190 50 12 [loeschen1] buttoncreate "f1 "b1_beenden [Beenden] 255 205 50 12 [beenden1] end to dechexzahl :wort output (vorkommazahl vorkomma :wort 16) + (nachkommazahl nachkomma :wort 16) end to explinks :wort ifelse (first :wort) = ".~ [output -1]~ [output 1 + explinks butfirst :wort] end to exprechts :wort ifelse (first :wort) = "1~ [output 1]~ [output -1 + exprechts butfirst :wort] end to ganzanteil :zahl output int :zahl end to ganzbin :ganzzahl ifelse :ganzzahl = 0~ [output "]~ [output word (ganzbin ganzanteil :ganzzahl / 2)~ (binzeichen rest :ganzzahl 2)] end to ganzhex :ganzzahl ifelse :ganzzahl = 0~ [output "]~ [output word (ganzhex ganzanteil :ganzzahl / 16)~ (hexzeichen rest :ganzzahl 16)] end to gebranteil :zahl output :zahl - int :zahl end to gebrbin :gebrzahl output gebrbinhilfe :gebrzahl 1 end to gebrbinhilfe :gebrzahl :n ifelse :gebrzahl = 0~ [output "]~ [ifelse :n = 256~ [output binzeichen ganzanteil :gebrzahl * 2]~ [output word (binzeichen ganzanteil :gebrzahl * 2)~ (gebrbinhilfe gebranteil :gebrzahl * 2 :n + 1)]] end to gebrhex :gebrzahl output gebrhexhilfe :gebrzahl 1 end to gebrhexhilfe :gebrzahl :n ifelse :gebrzahl = 0~ [output "]~ [ifelse :n = 64~ [output hexzeichen ganzanteil :gebrzahl * 16]~ [output word (hexzeichen ganzanteil :gebrzahl * 16)~ (gebrhexhilfe gebranteil :gebrzahl * 16 :n + 1)]] end to gleitdec make "f2? "true make "sb2_1? "false windowcreate "hf "f2 [Umwandlung von 32-Bit-Gleitkommazahlen in Dezimalzahlen] 0 0 320 240 [] staticcreate "f2 "l2_1 [Geben Sie die Gleitkommazahl an:] 10 12 120 12 comboboxcreate "f2 "e2_1 125 10 50 12 staticcreate "f2 "l2_2 [hexadezimal] 180 12 115 12 buttoncreate "f2 "b2_berechnen [Berechnen] 255 10 50 12 [berechnen2] staticcreate "f2 "l2_3 [Ausgabe im Dualsystem:] 10 30 150 12 comboboxcreate "f2 "e2_2 10 40 295 12 staticcreate "f2 "l2_4 [Vorzeichen der Gleitkommazahl:] 10 62 120 12 comboboxcreate "f2 "e2_3 125 60 50 12 staticcreate "f2 "l2_5 [---> 1. Bit] 180 62 50 12 staticcreate "f2 "l2_6 [Charakter des Exponenten:] 10 77 120 12 comboboxcreate "f2 "e2_4 125 75 100 12 staticcreate "f2 "l2_7 [---> 2. - 9. Bit] 230 77 80 12 staticcreate "f2 "l2_8 [Exponent der Gleitkommazahl:] 10 92 120 12 comboboxcreate "f2 "e2_5 125 90 50 12 staticcreate "f2 "l2_9 [Mantisse der Gleitkommazahl:] 10 110 170 12 comboboxcreate "f2 "e2_6 10 120 215 12 staticcreate "f2 "l2_10 [---> 10. - 32. Bit] 230 122 80 12 staticcreate "f2 "l2_11 [Ausgabe der gespeicherten Zahl, dual:] 10 140 170 12 comboboxcreate "f2 "e2_7 10 150 295 12 staticcreate "f2 "l2_12 [Ausgabe der gespeicherten Zahl, hexadezimal:] 10 165 170 12 comboboxcreate "f2 "e2_8 10 175 215 12 staticcreate "f2 "l2_13 [Ausgabe der gespeicherten Zahl, dezimal:] 10 190 170 12 comboboxcreate "f2 "e2_9 10 200 215 12 buttoncreate "f2 "b2_loeschen [Loeschen] 255 190 50 12 [loeschen2] buttoncreate "f2 "b2_beenden [Beenden] 255 205 50 12 [beenden2] end to gross :buchstabe ifelse (ascii :buchstabe) > (ascii "Z)~ [output char ((ascii :buchstabe) + (ascii "A) - (ascii "a))]~ [output :buchstabe] end to grosswort :wort ifelse (count :wort) = 0~ [output :wort]~ [output word (gross first :wort) (grosswort butfirst :wort)] end to hexdeczahl :zahl ifelse (ganzanteil :zahl) = 0~ [ifelse (gebranteil :zahl) = 0~ [output "0]~ [output word "0. gebrhex gebranteil :zahl]]~ [ifelse (gebranteil :zahl) = 0~ [output ganzhex ganzanteil :zahl]~ [output (word ganzhex ganzanteil :zahl ". gebrhex gebranteil :zahl)]] end to hexeingabe ifelse emptyp comboboxgettext "e2_1~ [output [false]]~ [make "wort vornullen grosswort first comboboxgettext "e2_1 8~ ifelse (kontrolle :wort [0 1 2 3 4 5 6 7 8 9 A B C D E F]) = 8~ [output :wort]~ [output [false]]] end to hexzeichen :zahl ifelse memberp :zahl [0 1 2 3 4 5 6 7 8 9]~ [output char (48 + :zahl)]~ [output char (55 + :zahl)] end to kommalinks :wort :pos output word "0. vornullen :wort :pos + count :wort end to kommalinkssetzen :wort :pos output (word first :wort ". butfirst :wort) end to kommarechts :wort :pos ifelse :pos < count :wort~ [ifelse :pos = 0~ [output word ". :wort]~ [output word (first :wort) (kommarechts butfirst :wort :pos - 1)]]~ [output nachnullen :wort :pos] end to kommarechtssetzen :wort :pos ifelse :pos = 0~ [output (word first :wort ". butfirst :wort)]~ [output kommarechtssetzen butfirst :wort :pos - 1] end to kommaverschieben :wort :pos ifelse :pos = 0~ [output :wort]~ [ifelse :pos < 0~ [output kommarechtssetzen streichkomma :wort betrag :pos]~ [output kommalinkssetzen streichkomma :wort :pos]] end to kontrolle :wort :liste ifelse emptyp :wort~ [output 0]~ [ifelse memberp (first :wort) :liste~ [make "zaehler 1]~ [make "zaehler 0]~ output :zaehler + kontrolle butfirst :wort :liste] end to loeschen1 comboboxsettext "e1_1 [] loeschen1_1 end to loeschen1_1 comboboxsettext "e1_2 [] comboboxsettext "e1_3 [] comboboxsettext "e1_4 [] comboboxsettext "e1_5 [] comboboxsettext "e1_6 [] comboboxsettext "e1_7 [] comboboxsettext "e1_8 [] comboboxsettext "e1_9 [] if :sb1_1? [scrollbardelete "sb1_1 make "sb1_1? "false] if :sb1_2? [scrollbardelete "sb1_2 make "sb1_2? "false] end to loeschen2 comboboxsettext "e2_1 [] loeschen2_1 end to loeschen2_1 comboboxsettext "e2_2 [] comboboxsettext "e2_3 [] comboboxsettext "e2_4 [] comboboxsettext "e2_5 [] comboboxsettext "e2_6 [] comboboxsettext "e2_7 [] comboboxsettext "e2_8 [] comboboxsettext "e2_9 [] if :sb2_1? [scrollbardelete "sb2_1 make "sb2_1? "false] end to nachkomma :wort ifelse not memberp ". :wort~ [output "]~ [output butfirst member ". :wort] end to nachkommahilfe :erg :wort :basis ifelse emptyp :wort~ [output :erg]~ [ifelse emptyp butlast :wort~ [output (:erg / :basis + wandeln last :wort) / :basis]~ [output nachkommahilfe :erg / :basis + wandeln last :wort butlast :wort :basis]] end to nachkommazahl :wort :basis output nachkommahilfe 0 :wort :basis end to nachnullen :wort :bit ifelse :bit = count :wort~ [output :wort]~ [output nachnullen word :wort "0 :bit] end to nachstellen :wort :bit ifelse :bit < count :wort~ [output nachstreichen :wort :bit]~ [output nachnullen :wort :bit] end to nachstreichen :wort :bit ifelse :bit = count :wort~ [output :wort]~ [output nachstreichen butlast :wort :bit] end to programmende if :f1? [beenden1] if :f2? [beenden2] windowdelete "hf unicon [MswLogo Screen] unicon "Commander end to rest :ganzzahl1 :ganzzahl2 output :ganzzahl1 - :ganzzahl2 * int (:ganzzahl1 / :ganzzahl2) end to scrollbis :l :wort ifelse :l < count :wort~ [op (count :wort) - :l]~ [op 0] end to scrollen :name :pos :l :wort comboboxsettext :name textfenster :pos :l :wort end to start icon "Commander icon [MswLogo Screen] make "f1? "false make "f2? "false windowcreate "main "hf [Gleitkommazahlen im normalisierten IEEE-Format] 0 0 320 120 [] staticcreate "hf "l_beschreibung [Dieses Programm demonstriert die Codierung~ von 32 - Bit - Gleitkommazahlen im normalisierten~ IEEE - Format. Die Normalisierung wird auch bei~ sehr kleinen Werten nicht aufgehoben.] 5 5 310 30 staticcreate "hf "l_auswahl [Waehlen Sie aus: ] 90 39 100 10 buttoncreate "hf "b_decgleit [Dezimalzahl ---> Gleitkommazahl] 160 35 120 16 [if not :f1? [decgleit]] buttoncreate "hf "b_gleitdec [Gleitkommazahl ---> Dezimalzahl] 160 55 120 16 [if not :f2? [gleitdec]] buttoncreate "hf "b_ende [Programm beenden] 160 75 120 16 [programmende] end to streichkomma :wort ifelse not memberp ". :wort~ [output :wort]~ [ifelse (first :wort) = ".~ [output butfirst :wort]~ [output word (first :wort) (streichkomma butfirst :wort)]] end to teilewort :wort :pos output teilhilfe " :wort :pos end to teilhilfe :wort1 :wort2 :pos ifelse :pos = count :wort1~ [output list :wort1 :wort2]~ [output teilhilfe word :wort1 first :wort2 butfirst :wort2 :pos] end to textab :pos :wort ifelse :pos = 0~ [op :wort]~ [op textab :pos - 1 bf :wort] end to textbis :pos :wort ifelse or (:pos > count :wort) (:pos = count :wort)~ [op :wort]~ [op textbis :pos bl :wort] end to textfenster :pos :l :wort op textbis :l textab :pos :wort end to umwandeln1 make "fenster1 73 make "dezimalwort :dezimalzahl make "dualzahl bindeczahl betrag :dezimalzahl make "hexadezimalzahl hexdeczahl betrag :dezimalzahl ifelse (first :dezimalwort) = "-~ [make "vzbit "1 make "vz "-]~ [make "vzbit "0 make "vz "] make "text1_1 word :vz :dualzahl if :sb1_1?~ [scrollbardelete "sb1_1 make "sb1_1? "false] ifelse :fenster1 < count :text1_1~ [scrollbarcreate "f1 "sb1_1 255 52 50 12~ [scrollen "e1_2 scrollbarget "sb1_1 :fenster1 :text1_1]~ scrollbarset "sb1_1 0 scrollbis :fenster1 :text1_1 0~ make "sb1_1? "true]~ [comboboxsettext "e1_2 :text1_1] make "text1_2 word :vz :hexadezimalzahl if :sb1_2?~ [scrollbardelete "sb1_2 make "sb1_2? "false] ifelse :fenster1 < count :text1_2~ [scrollbarcreate "f1 "sb1_2 255 77 50 12~ [scrollen "e1_3 scrollbarget "sb1_2 :fenster1 :text1_2]~ scrollbarset "sb1_2 0 scrollbis :fenster1 :text1_2 0~ make "sb1_2? "true]~ [comboboxsettext "e1_3 :text1_2] ifelse :dezimalzahl = 0~ [make "exponent -127~ make "mantisse nachstellen "0 23~ make "charakter vornullen "0 8]~ [make "exponent binexp :dualzahl~ make "dualzahl kommaverschieben :dualzahl :exponent~ ifelse :dualzahl = "1~ [make "mantisse nachstellen "0 23]~ [make "mantisse nachstellen (butfirst butfirst :dualzahl) 23]~ make "charakter vornullen (bindeczahl (:exponent + 127)) 8] comboboxsettext "e1_4 :vzbit comboboxsettext "e1_5 (se :exponent [(dec)]) comboboxsettext "e1_6 (se (:exponent + 127) [(dec) =] :charakter [(bin)]) comboboxsettext "e1_7 (se :mantisse [(bin)]) make "gleitdual (word :vzbit :charakter :mantisse) comboboxsettext "e1_8 (se :gleitdual [(bin)]) make "dualliste teilewort :gleitdual 16 make "gleithex word (vornullen hexdeczahl decbinzahl first :dualliste 4)~ (vornullen hexdeczahl decbinzahl last :dualliste 4) comboboxsettext "e1_9 (se :gleithex [(hex)]) end to umwandeln2 make "fenster2 73 make "dualzahl binhexzahl :hexadezimalzahl comboboxsettext "e2_1 :hexadezimalzahl comboboxsettext "e2_2 (se :hexadezimalzahl [(hex) =] :dualzahl [(bin)]) ifelse (first :dualzahl) = "1~ [make "vztext "negativ make "vz "-]~ [make "vztext "positiv make "vz "] make "dualzahl butfirst :dualzahl make "dualliste teilewort :dualzahl 8 make "charakter first :dualliste make "exponent (decbinzahl :charakter) - 127 make "mantisse last :dualliste comboboxsettext "e2_3 :vztext comboboxsettext "e2_4 (se :charakter [(bin) =] decbinzahl :charakter [(dec)]) comboboxsettext "e2_5 (se :exponent [(dec)]) comboboxsettext "e2_6 (se :mantisse [(bin)]) ifelse and (not memberp "1 :mantisse) (not memberp "1 :charakter)~ [make "bingleitkomma word :vz "0]~ [ifelse :exponent < 0~ [make "bingleitkomma word :vz kommalinks word "1 :mantisse (betrag :exponent) - 1]~ [make "bingleitkomma (word :vz "1 kommarechts :mantisse :exponent)]] make "text2_1 (word :bingleitkomma "| | "|(|bin|)|) if :sb2_1?~ [scrollbardelete "sb2_1 make "sb2_1? "false] ifelse :fenster2 < count :text2_1~ [scrollbarcreate "f2 "sb2_1 255 162 50 12~ [scrollen "e2_7 scrollbarget "sb2_1 :fenster2 :text2_1]~ scrollbarset "sb2_1 0 scrollbis :fenster2 :text2_1 0~ make "sb2_1? "true]~ [comboboxsettext "e2_7 :text2_1] ifelse :vztext = "negativ~ [make "decgleitkomma (-1) * decbinzahl butfirst :bingleitkomma]~ [make "decgleitkomma decbinzahl :bingleitkomma] ifelse :vztext = "negativ~ [make "hexgleitkomma word :vz hexdeczahl betrag :decgleitkomma]~ [make "hexgleitkomma hexdeczahl :decgleitkomma] comboboxsettext "e2_8 (se :hexgleitkomma [(hex)]) comboboxsettext "e2_9 (se :decgleitkomma [(dec)]) end to vorkomma :wort ifelse emptyp :wort~ [output "]~ [ifelse (first :wort) = ".~ [output "]~ [output word (first :wort) (vorkomma butfirst :wort)]] end to vorkommahilfe :erg :wort :basis ifelse emptyp :wort~ [output :erg]~ [ifelse emptyp butfirst :wort~ [output :erg * :basis + wandeln first :wort]~ [output vorkommahilfe :erg * :basis + wandeln first :wort butfirst :wort :basis]] end to vorkommazahl :wort :basis output vorkommahilfe wandeln first :wort butfirst :wort :basis end to vornullen :wort :bit ifelse or (:bit = count :wort) (:bit < count :wort)~ [output :wort]~ [output vornullen word "0 :wort :bit] end to wandeln :buchstabe ifelse memberp :buchstabe [0 1 2 3 4 5 6 7 8 9]~ [output (ascii :buchstabe) - 48]~ [output (ascii :buchstabe) - 55] end