Basic DataTypes

Like any regular programming language, Type-C provides basic built-in data types. These types have a guaranteed fixed size, ensuring that the data they represent occupies a constant amount of memory, regardless of the platform. This is crucial for low-level operations and provides more predictable behavior for high-performance computing tasks.

NameExplanationRange
u88bit wide unsigned integer0 to 255
i88-bit wide signed integer-128 to 127
u1616-bit wide unsigned integer0 to 65,535
i1616-bit wide signed integer-32,768 to 32,767
u3232-bit wide unsigned integer0 to 4,294,967,295
i3232-bit wide signed integer-2,147,483,648 to 2,147,483,647
u6464-bit wide unsigned integer0 to 18,446,744,073,709,551,615
i6464-bit wide signed integer-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
f3232-bit wide floating number3.4 × 10^38 (7 digits)
f6464-bit wide floating point number1.7 × 10^308 (15 digits)
boolBoolean value (8-bit sized)true or false
voidUsually a return type for functions that has no return value
nullUsed both as a type and a value, to indicate that an object is nullable

Type-C does not provide C compatibility types for basic types, instead, u8 is compatible with C99 uint8_t, same for all others.

Type Casting between basic types

Type casting in not an instant instruction, inorder to attempt to maintain type safety, Type-C will cast an intermediate type to the target type. This is to prevent loss of data or unexpected results, when applicable.

For example:

In the above example, x is a floating point number, and z is an unsigned integer. The compiler will first convert x into u32, then to u8.


Kudos! Keep reading!