binary2decimal Modul
Übersicht

SebeBetreff: binary2decimal Modul |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hab festgestellt, dass BMX zwar ganz einfach Dezimalzahlen in Binärzahlen umwandeln kann, umgekehrt geht das aber nicht. Deshalb hier ein kleines Modul mit dem das geht:
Code: [AUSKLAPPEN] 'File.............. b2d.bmx 'Description....... module for casting binary values to decimal values 'Author............ Sebastian Erben 'Email............. sebe@infernalsoftware.com '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Date of start..... 16th January 2005 'Current version... Final1 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Import brl.system Import brl.retro Module pub.b2d ModuleInfo "Version: 1.0" ModuleInfo "Author: Sebastian Erben" ModuleInfo "License: LGPL" ModuleInfo "Copyright: 2005 by Infernal Software" Function b2d:Int(binaryvalue:String) 'Set up the function variables Local counter:Int = 0 Local caststring:String = "" Local castnumber:Int = 0 Local decimalvalue:Int = 0 'Cast binaryvalue to decimalvalue For counter% = 0 To Len(binaryvalue$) caststring$ = Mid(binaryvalue$, counter% + 1, 1) castnumber% = caststring$.toint() decimalvalue%:+ castnumber * (2 ^ (Len(binaryvalue$) - counter%)) Next 'Give back the decimal value Return decimalvalue% EndFunction Ich denke die Funktion ist selbsterklärend, aber zur Sicherheit: Dezimalzahl% = b2d%(Binärzahl$) Viel Spaß damit 8) |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group