Michael Clease
26-05-2007, 18:22
' Usage of the BIN$ Instruction example
'
' Returns Binary Version of a number
'
' Written by Abraxas
DIM Base10Num as DWORD value &hAAAA5555
DIM TempVal As DWORD Value Base10Num
DIM n as byte value 0
Dim sMsg as String
sMsg += "Base10 = " & Base10Num & $CRLF
sMsg += "Binary = " & Bin$(Base10Num,32) & $CRLF
sMsg += "Binary Nibbles = "
' This Groups 4 bits (a nibble)
For n = 28 to 0 step -4
TempVal = Base10Num
sMsg += " " & Bin$((SHIFT SIGNED RIGHT TempVal,n),4)
Next
sMsg += $CRLF
sMsg += "Hex = &h" & Hex$(Base10Num,8)
MsgBox 0, sMsg ' Display The information
'
' Returns Binary Version of a number
'
' Written by Abraxas
DIM Base10Num as DWORD value &hAAAA5555
DIM TempVal As DWORD Value Base10Num
DIM n as byte value 0
Dim sMsg as String
sMsg += "Base10 = " & Base10Num & $CRLF
sMsg += "Binary = " & Bin$(Base10Num,32) & $CRLF
sMsg += "Binary Nibbles = "
' This Groups 4 bits (a nibble)
For n = 28 to 0 step -4
TempVal = Base10Num
sMsg += " " & Bin$((SHIFT SIGNED RIGHT TempVal,n),4)
Next
sMsg += $CRLF
sMsg += "Hex = &h" & Hex$(Base10Num,8)
MsgBox 0, sMsg ' Display The information