Introduction

The data types in BCD format belong to the EDT (Elementary data type) family, which includes single rather than derived data types (tables, structures, function blocks).

Reminder Concerning BCD Format

The Binary Coded Decimal (BCD) format is used to represent decimal numbers between 0 and 9 using a group of four bits (half-byte).

In this format, the four bits used to code the decimal numbers have a range of unused combinations.

Correspondence table:

Decimal

Binary

0

0000

1

0001

2

0010

3

0011

4

0100

5

0101

6

0110

7

0111

8

1000

9

1001

 

1010 (unused)

 

1011 (unused)

 

1100 (unused)

 

1101 (unused)

 

1110 (unused)

 

1111 (unused)

Example of coding using a 16 bit format:

Decimal value

2450

2

4

5

0

Binary value

0010

0100

0101

0000

Example of coding using a 32 bit format:

Decimal value

78993016

7

8

9

9

3

0

1

6

Binary value

0111

1000

1001

1001

0011

0000

0001

0110

Data Types in BCD Format

Three data types:

Type

Designation

Scale (bits)

Default value

DATE

Date

32

D#1990-01-01

TIME_OF_DAY

Time of day

32

TOD#00:00:00

DATE_AND_TIME

Date and Time

64

DT#1990-01-01-00:00:00