Primitive types are indivisible value types that are built into the language.
Numeric Types
CM supports a wide range of numeric types with different sizes to accommodate many needs.
For every numeric type, there are two constants that contain the minimal and maximal values possible for that type. These constants are named minType and maxType, where Type is the name of the type with its first letter capitalized.
For instance, the minInt and maxInt constants contain the bounds of the int type.
Integral Types
Operations on integral types that lead to under- or overflow cause the number to wrap around. For instance, the addition of byte values is addition modulo 256.
int
Values of type int are 32-bit signed integers.
range: -2147483648..2147483647
Integer literals can be specified in hexadecimal form (base 16) by prefixing the number with 0x.
nat
Values of type nat are 32-bit unsigned integers.
range: 0..4294967295
Integer literals can be specified in hexadecimal form (base 16) by prefixing the number with 0x.
nat64
Values of type nat are 64-bit unsigned integers.
range: 0..9223372036854775807
Integer literals can be specified in hexadecimal form (base 16) by prefixing the number with 0x.
byte
Values of type byte are 8-bit unsigned integers.
range: 0..255
int8
Values of type int8 are 8-bit signed integers.
range: -128..127
int16
Values of type int16 are 16-bit signed integers.
range: -32768..32767
word
Values of type word are 16-bit unsigned integers.
range: 0..65535
int64
Values of type nat are 64-bit signed integers.
Literals of type int64 are written with i64 appended at the end of the number.
range: -9223372036854775808..9223372036854775807
Floating-Point Types
double
Values of type double contain double-precision 64-bit floating-point values.
range: -1.79769e+308..1.79769e+308
float
Values of type float contain single-precision 32-bit floating-point values.
range: -3.40282e+038..3.40282e+038
Character Types
char
Values of type char are wide characters (16 bits) representing UTF-16 code units.
cchar
Values of type cchar are 8-bit characters used for compatibility with C.
Boolean Types
bool
The bool type represents truth values and can be either true or false.
Comments
0 comments
Please sign in to leave a comment.