LWORD_TO_BINSTR

LWORD_TO_BINSTR 1:

This function converts a decimal number into a binary string (base 2).

LWORD_TO_BINSTR 2: Return value

Name

Type

Description

LWORD_TO_BINSTR

T_MaxString

 

LWORD_TO_BINSTR 3: Inputs

VAR_INPUT
    in         : LWORD;
    iPrecision : INT;
END_VAR

Name

Type

Description

in

LWORD

The decimal number to be converted.

iPrecision

INT

Minimum number of displayed digits. If the actual number of significant digits is less than the iPrecision parameter, the resulting string is filled with zeros from the left. If the number of significant digits is greater than the iPrecision parameter, the resulting string is not truncated! If the iPrecision parameter and the in parameter have the value zero, the resulting string is an empty string.

Example:

PROGRAM MAIN
VAR
    s1   : STRING;
    s2   : STRING;
    s3   : STRING;
    nCnt : LWORD;
END_VAR
s1   := LWORD_TO_BINSTR( 16#81, 16 );
nCnt := 15;
s2   := LWORD_TO_BINSTR( nCnt, 1 );
nCnt := 0;
s3   := LWORD_TO_BINSTR( nCnt, 0 );

The result:

s1 = '0000000010000001'

s2 = '1111'

s3 = ''

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, Arm®)

Tc2_Utilities (System)