Skip to main content

Constant: Numeric

Numeric values can be binary, octal, decimal, and hexadecimal numbers. If an integer value is not a decimal number, then you must write its base followed by the number sign (#) before the integer constant. You enter the hexadecimal digit values for the numbers 10 to 15 as usual with the letters A-F.

You can use an underscore within a numeric value.

Example 180. Examples:

14

Decimal number

2#1001_0011

Binary number

8#67

Octal number

16#A

Hexadecimal number

DINT#16#A1

Typed data type DINT# and base 16# combined



Possible data types for a numerical literal:

BYTE, WORD, DWORD, LWORD, SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT

Tip

Implicit conversions from "larger" to "smaller" types are not permitted. You cannot simply use a DINT variable as an INT variable. For this, you have to use a type conversion function.

For more information, see: Constant: Typed Literal

Tip

Because number constants are basically handled as integer values, in divisions you have to specify the constant in floating point number format to avoid losing the remainder.

Examples: Division of 1/10 yields 0 and division of 1.0/10 yields 0.1