Skip to main content

Type System

Primitive Types

TypeSizeRange
int32-bit-2,147,483,648 to 2,147,483,647
int6464-bit-9.2 × 10¹⁸ to 9.2 × 10¹⁸
uint6464-bit0 to 1.8 × 10¹⁹
float64-bitDouble precision
strString
bool1-bittrue or false
int x = 42
int64 big = 9223372036854775807
uint64 huge = 18446744073709551615
float pi = 3.14159
str name = "Cpyte"
bool valid = true

64-bit Integers

# Hex literals
int64 hex_max = 0x7FFFFFFFFFFFFFFF
uint64 hex_u64 = 0xFFFFFFFFFFFFFFFF

# Type promotion
int small = 42
int64 large = 1000000000000
int64 result = small + large # small promoted to int64

Pointers

int* ptr = new int
*ptr = 42

int** pptr = &ptr
print(**pptr) # 42

int64* large_ptr = new int64
uint64* unsigned_ptr = new uint64

Arrays

int[] numbers = new int[10]
numbers[0] = 1
numbers[9] = 99

str[] names = new str[5]
names[0] = "Alice"

# 64-bit arrays
int64[] big_data = new int64[1000000]

Type Inference

The compiler infers types from literals and expressions:

x = 42 # int
y = 3.14 # float
big = 9223372036854775807 # int64
result = x + y # float

Sizeof

int_size = sizeof(int) # 4
ptr_size = sizeof(void*) # 8