PDA

View Full Version : Usage of the Bin$ Keyword



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

ErosOlmi
27-05-2007, 01:24
Perfect.

kryton9
27-05-2007, 09:53
These are nice because I don't remember ever using such commands before. Seeing a to the point example is a great idea.