Numeric data types – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 19

Advertising
background image

Publication 1746-RM001A-US-P

Data Types 2-3

Numeric Data Types

There are two different numeric data types:

integer numbers

floating-point numbers

You can enter and display numbers in four formats: integer, decimal, hexadecimal,
and exponential.

Example

129, 34.98, 0A6EH, 1.23456E+3

The BASIC or BASIC-T module interprets all numbers as floating-point numbers
except when performing logical operations. When performing logical operations,
the module converts floating-point numbers to integers, performs the operation,
then converts the result back to floating-point.

Integer Numbers

The module operates on unsigned 16-bit integers that range from 0 to 65535 or
0FFFFH. You can enter all integers in either decimal or hexadecimal format. You
indicate a hexadecimal number by placing the character H after the number
(example: 170H). If the hexadecimal number begins with A through F, then it
must be preceded by a zero. (For example, you must enter A567H as 0A567H.)
When an operator, such as .AND. requires an integer, the module truncates the
fraction portion of the number so it fits the integer format. Integers are shown as:

[integer]

Floating-Point Numbers

In the module, all numbers are stored as floating-point numbers. Floating-point
numbers are numbers in which the decimal point floats depending on the
significant digits of a specific number. The processor accounts for the location of
the decimal point. This allows the processor to store only the significant digits of a
value, thus saving memory space.

You can represent the following range of numbers in the module:

+1E –127 to +.99999999 +127

There are eight significant digits. Numbers are internally rounded to fit this
precision.

IMPORTANT

The SLC 500 processor operates on signed 16-bit integers that
range from –32768 to 32767. If an integer value larger than
32767 is passed to the processor from the module, that value is
interpreted as negative by the processor.

Advertising