Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Return a string that is the binary (base 2) representation of its argument.

 

Syntax

 

s = BIN$(NumericExpression [, Digits])

 

Returns

 

String

 

Parameters

 

Name

Type

Optional

Meaning

NumericExpression

Number

No

The numeric expression you want transform into binary format.

Digits

Number

Yes

If digits is specified, the resulting string will be of length digits.

 

Remarks

 

Restrictions

 

See also

 

String Handling,

 

Examples

 

Thanks to Abraxas for the following script example

'---Usage of the BIN$ Instruction example

'---Returns Binary Version of a number

 

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

 

 

 

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software