Next: , Previous: , Up: Integers   [Contents][Index]

18.1.4 Integer Types

Most general-purpose programming languages provide a small set of integer types, each featuring a range corresponding to strategic storage sizes: basically, signed and unsigned variants of 8, 16, 32, 64 bits. As we have seen in the previous sections, suffixes like `H` or `L` are used in Poke for that purpose.

However, in conventional programming languages when integers having an “odd” width (like 13 bits, for example) get into play for whatever reason, the programmer is required to use the integer arithmetic operators (and sometimes bit-wise operators) herself, in a clever way, in order to achieve the desired results.

Poke, on the contrary, provides a rich set of integer types featuring different widths, in both signed and unsigned variants. The language operators are aware of these types, and will do the right thing when operating on integer values having different widths.

Unsigned integer types are specified using the type constructor `uint<n>`, where n is the number of bits. n should be an integer literal in the range `[1,64]`. Examples:

```uint<1>
uint<7>
uint<64>
```

Similarly, signed integer types are created using the type constructor `int<n>`, where n is the number of bits. n should be an integer literal in the range `[1,64]`. Examples:

```int<1>
int<8>
int<64>
```

Note that expressions are not allowed in the type integral constructor parameters. Not even constant expressions. Thus, things like `int<foo>` and `uint<2+3>` are not allowed.