home *** CD-ROM | disk | FTP | other *** search
/ 64'er 1991 June / 64er_Magazin_91-06_1991_Markt__Technik_de.d64 / dualhexe (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  948b  |  42 lines

  1. 10 print"[147]":rem umrechnung hexzahl in dualzahl
  2. 20 print" umrechnung hexzahl in dualzahl"
  3. 30 print" ******************************"
  4. 40 print:print:input" hexzahl:";h$
  5. 50 l=len(h$)
  6. 60 fori=lto1step-1
  7. 70 s$=mid$(h$,i,1)
  8. 75 ifasc(s$)>70thenprint" keine hexzahl!":goto40
  9. 80 ifasc(s$)<58thende=asc(s$)-48
  10. 85 ifasc(s$)>64thende=asc(s$)-55
  11. 90 ifde/2<>int(de/2)thendu$="1"+du$
  12. 100 ifde/2=int(de/2)thendu$="0"+du$
  13. 105 de=int(de/2)
  14. 110 ifde>=1then90
  15. 115 ifi=1then125
  16. 120 iflen(du$)<4thendu$="0"+du$:goto120
  17. 125 e$=du$+e$
  18. 130 de=0:du$=""
  19. 135 nexti
  20. 140 print:print" dualzahl="e$
  21. 150 du$="":e$="":goto40
  22. 200 print"[147]":rem umrechnung dualzahl in hexzahl
  23. 210 print" umrechnung dualzahl in hexzahl"
  24. 220 print" ******************************"
  25. 230 print:print:input" dualzahl:";du$
  26. 235 l=len(du$)
  27. 240 ifl/4=int(l/4)then270
  28. 250 f=4-(l/4-int(l/4))*4
  29. 260 fort=1tof:du$="0"+du$:nextt
  30. 270 fori=1tolstep4
  31. 280 t$=mid$(du$,i,4)
  32. 285 rem bis zeile 320 horner-schema
  33. 290 de=val(mid$(t$,1,1))
  34. 300 fork=1to3
  35. 310 de=de*2+val(mid$(t$,k+1,1))
  36. 320 nextk
  37. 330 ifde<=9thenh$=h$+str$(de)
  38. 340 ifde>9thenh$=h$+chr$(de+55)
  39. 350 de=0:nexti
  40. 360 print:print" hexzahl="h$
  41. 370 h$="":goto230
  42.