Skip to content

IntToBin2 ​

IntToBin2 converts an Integer value into a String of binary digits (i.e. a series of 0's and 1's).

The number of binary 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.

Also refer to IntToBin.

Declaration: Function IntToBin2( v : LongInt) : string

For example, IntToBin2(257) generates 0000000100000001.

pascal
procedure OnMapEvent(var Value:Variant);
var
  My1stAmount, My2ndAmount, My3rdAmount : Integer;
begin
  My1stAmount := 123;
  My2ndAmount := 5677;
  My3rdAmount := 257;
  LogInfo(IntToBin2(My1stAmount));           // outputs 01111011
  LogInfo(IntToBin2(My2ndAmount));           // outputs 001011000101101
  LogInfo(IntToBin2(My3rdAmount));           // outputs 000000100000001
end;