Data types: uint8, uint16, uint32

Represents an unsigned integer number stored with 8, 16 or 32 bit.

Type syntax

uint8

uint16

uint32

Literal syntax

decimal‑literal

0xhex‑decimal‑literal

Discussion

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

Number of bits

Min. value

Max. value

8 bit

0

255

16 bit

0

65535

32 bit

0

4294967295

The unsigned integer numbers may be expressed in either decimal or hexadecimal notation. A number in hexadecimal notation begins with the prefix 0x. The literals can be used within expressions wherever an uint8, uint16 or uint32 operand is expected. The type names, in turn, are designated to be used in declarations of data members. For example:

var uint32 options = 0xF7700088; var uint16 voltage = 6000;

Arithmetic operations

You can combine an unsigned 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 unsigned 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 unsigned 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 unsigned 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 an unsigned integer number.

Parsing a string as an unsigned integer number.