Basic Types

Frost provides a robust set of primitive types designed for systems programming, offering both safety and performance.

Numeric Types

Int (Integer)

The standard integer type in Frost represents whole numbers:

age: int = 20

Properties

  • Size: 32 bits (4 bytes)

  • Range: -2,147,483,648 to 2,147,483,647

  • Default value: 0

Float (Single-precision)

Floats in Frost have some quirks.

One quirk of Frost is the use of commas (,) instead of periods for floating-point numbers.

Another one, is that floating-point numbers are treated as double unless explicitly marked as float. This can be done either by appending an f to the number or by using the cast expression:

temperature: float = 23,5f

32-bit floating-point numbers following IEEE 754:

Properties

  • Size: 32 bits (4 bytes)

  • Precision: ~7 decimal digits

  • Range: ±3.4E±38

Double (Double-precision)

Similar to float, double have a suffix d to differentiate them from float

64-bit floating-point numbers for higher precision calculations:

Properties

  • Size: 64 bits (8 bytes)

  • Precision: ~15-17 decimal digits

  • Range: ±1.7E±308

Character Types

Char

Represents a single Unicode character:

Properties

  • Size: 8 bits (1 byte)

  • Encoding: UTF-8

  • Default value: '\0'

Boolean Type

Boolean

Represents logical true/false values:

Properties

  • Size: 1 byte

  • Values: true, false

  • Default value: false

Special Types

Never

Represents the absence of a type, commonly used in functions that don't return values:

Type Conversion

Frost provides safe type conversion mechanisms:

Memory Alignment

Types are automatically aligned for optimal performance:

Remember that Frost's type system is designed to prevent common programming errors while maintaining performance. The compiler performs extensive type checking at compile-time to ensure type safety in your programs.

Last updated