bcd_to_sint/int/dint (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

ALL

Firmware version:

1.00 / 1.00.00


The "bcd_to_xxx" function operates on the SINT, INT, and DINT data types. It will convert a BCD-packed value into its binary representation.

 

 

Input:

in : DINT/INT/SINT

The BCD-packed value to convert.

 

Returns: DINT/INT/SINT

The resulting binary value.

 

Declaration:

 

FUNCTION bcd_to_dint : DINT;
VAR_INPUT
  in : DINT;
END_VAR;
 
FUNCTION bcd_to_int : INT;
VAR_INPUT
  in : INT;
END_VAR;
 
FUNCTION bcd_to_sint : SINT;
VAR_INPUT
  in : SINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
  a : INT;
  b : INT;
END_VAR;
 
PROGRAM test;
 
BEGIN
  a := 16#2215;
  // Convert 16#2215 (BCD representation), to 2215 in binary
  b := bcd_to_int(in:=a);
  // b is now 2215
  ...
END;
 
END_PROGRAM;