Data types: int8, int16, int32

Represents a signed integer number stored with 8, 16 or 32 bit.

Type syntax

int8

int16

int32

Literal syntax

+/-decimal‑literal

Discussion

The number of bits determines directly the range for the respective values:

Number of bits

Min. value

Max. value

8 bit

–128

127

16 bit

–32768

32767

32 bit

–2147483648

2147483647

The signed integer numbers must always be expressed as a sequence of digits with an optional + or - sign put in front of the number. The literals can be used within expressions wherever an int8, int16 or int32 operand is expected. The type names, in turn, are designated to be used in declarations of data members. For example:

var int32 voltage = 220000; var int16 current = -100;

Arithmetic operations

You can combine a signed integer operand with other operands to arithmetic expressions. The following table provides an overview of the possible operations:

Operator

Short description

+

Addition

-

Subtraction

*

Multiplication

/

Division

%

Modulo division

Bitwise operations

You can apply bitwise operations on signed integer operands. The operations are applied on all 8, 16 or 32 bits of the operand. The following table provides an overview of the possible operations:

Operator

Short description

~

Bitwise NOT

&

AND

|

OR

^

XOR

>>

Right shift

<<

Left shift

Comparison operations

You can compare two signed integer operands in order to test whether these are equal or not. The following table provides an overview of the possible operations:

Operator

Short description

==

Equality

!=

Inequality

<

Less than

>

Greater than

<=

Less than or equal

>=

Greater than or equal

Type conversions

Chora reacts sensitive when mixing operands of different data types within an operation. To avoid compiler warnings or even errors you can convert the affected operands explicitly by using following conversion operations:

Conversion operations with signed integers

Conversion between signed and unsigned integers.

Conversion to or from a floating-point value.

Conversion to or from an enumeration value.

Conversion to or from a set value.

Conversion to or from a char value.

Formatting a string from a signed integer number.

Parsing a string as a signed integer number.