INT_TO_BCD (FUN)

 

FUNCTION INT_TO_BCD : BYTE

Converts an INT value into a byte in BCD code

Example in ST:

i := INT_TO_BCD(49);  (* Result is 73 *)
k := BCD_TO_INT(97);  (* Result is 151 *)
l := BCD_TO_INT(100); (* Error! Output: 255 *)

InOut:

Scope

Name

Type

Comment

Return

INT_TO_BCD

BYTE

Value in BCD code for the input I

Input

I

INT

Value as INT. A wrong value (<0 or >99) causes a return of 255.