[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'System' (#rtl)

binStr

Convert integer to string with binary representation.

Declaration

Source position: line 0

function binStr(

  Val: LongInt;

  cnt: Byte

):shortstring;

function binStr(

  Val: Int64;

  cnt: Byte

):shortstring;

function binStr(

  Val: qword;

  cnt: Byte

):shortstring;

Description

BinStr returns a string with the binary representation of Value. The string has at most cnt characters. (i.e. only the cnt rightmost bits are taken into account) To have a complete representation of any longint-type value, 32 bits are needed, i.e. cnt=32

Errors

None.

See also

Str

  

Convert a numerical value to a string.

Val

  

Calculate numerical/enumerated value of a string.

HexStr

  

Convert integer value to string with hexadecimal representation.

OctStr

  

Convert integer to a string with octal representation.

Example

Program example82;

{ Program to demonstrate the BinStr function }

Const Value = 45678;

Var I : longint;

begin
  For I:=8 to 20 do
    Writeln (BinStr(Value,I):20);
end.
The latest version of this document can be found at lazarus-ccr.sourceforge.net.