Cyrus features a strong and expressive type system. The compiler performs implicit type conversions when it is safe, and requires explicit casts when conversions could be unsafe or lossy.
If a type can be safely converted to another type without losing information, Cyrus will perform the conversion automatically.
#a: int32 = 42;
#b: int64 = a; // Implicit cast from int32 to int64
int32
(32-bit signed integer) can always fit into int64
(64-bit signed integer).#x: float64 = 10.0
is allowed.If a conversion could be unsafe, the compiler requires an explicit cast using the cast
keyword.
#u: uint32 = 10;
#i: int64 = cast(int64, u); // Explicit unsafe cast from uint32 to int64
Cyrus provides a set of built-in types for numbers, characters, booleans, and special-purpose values. These are the fundamental building blocks of your programs.
Type | Category | Bit Width | Signedness |
---|---|---|---|
int | Signed Integer (default) | Target-dependent (usually 32 or 64) | Signed |
int8 | Signed Integer | 8 | Signed |
int16 | Signed Integer | 16 | Signed |
int32 | Signed Integer | 32 | Signed |
int64 | Signed Integer | 64 | Signed |
int128 | Signed Integer | 128 | Signed |
uint | Unsigned Integer (default) | Target-dependent (usually 32 or 64) | Unsigned |
uint8 | Unsigned Integer | 8 | Unsigned |
uint16 | Unsigned Integer | 16 | Unsigned |
uint32 | Unsigned Integer | 32 | Unsigned |
uint64 | Unsigned Integer | 64 | Unsigned |
uint128 | Unsigned Integer | 128 | Unsigned |
intptr | Pointer-sized Integer | Pointer width (32 or 64) | Signed |
uintptr | Pointer-sized Integer | Pointer width (32 or 64) | Unsigned |
size_t | Size / Index Type | Pointer width (32 or 64) | Unsigned |
Type | Description | Precision |
---|---|---|
float16 | 16-bit floating-point number (half precision) | ~3 decimal digits |
float32 | 32-bit floating-point number (single precision) | ~7 decimal digits |
float64 | 64-bit floating-point number (double precision) | ~15–16 decimal digits |
float128 | 128-bit floating-point number (quadruple precision) | ~34 decimal digits |
Type | Description | Notes |
---|---|---|
char | A single character unit (one code unit; multi-byte Unicode not allowed in '...' ). | Represents ASCII/byte chars only |
bool | Boolean values, either true or false . | 1-bit storage (typically padded to 8 bits) |
Type | Description | Notes |
---|---|---|
void | Represents no value, commonly used for functions that do not return anything. | Return type only |