Appearance
IntToBin
Declaration
Function IntToBin( v : LongInt; d : integer) : string
Function IntToBin2( v : LongInt) : string
Example
pascal
procedure OnMapEvent(var Value:Variant);
var MyAmount : Integer
begin
MyAmount := 123;
LogInfo(IntToBin(MyAmount, 10)); // outputs '0001111011'
LogInfo(IntToBin2(MyAmount)); // outputs '01111011'
Value := IntToBin(MyAmount,10);
end;Description
IntToBin converts an integer value into a String of binary digits (i.e. '0's and '1's). d specifies the number of digits in the string - if d is too small to represent all of the binary digits then an error will occur.
IntToBin2 converts an integer value into a String of binary digits (i.e. '0's and '1's). The number of digits is not specified; the resulting string will be the smallest multiple of 8 characters that can contain the binary representation (padded with leading zeroes). For example, IntToBin2(257) generates '0000000100000001'.
(This page updated in November 2018 to include the comment about d, and to include the related function IntToBin2.)