Overview
Expresiones is a statically-typed language with three primitive data types:int
Integer numbers
float
Floating-point numbers
bool
Boolean values
Integer Type (int)
The int type represents whole numbers without decimal points.
Declaration and Usage
Integer Literals
Integer literals are sequences of digits:Integers can be used in arithmetic operations and comparisons.
Floating-Point Type (float)
The float type represents numbers with decimal points.
Declaration and Usage
Float Literals
Float literals must include a decimal point followed by digits:Float Operations
Boolean Type (bool)
The bool type represents logical true/false values.
Declaration and Usage
In Expresiones, boolean values are represented using integers:
1 for true and 0 for false.Boolean in Conditionals
Type System
Static Typing
Expresiones requires explicit type declarations:Type Grammar
The formal grammar for types:Numeric Literals
Number Grammar
The grammar accepts both integer and floating-point literals:Valid Number Literals
Invalid Literals
Complete Example
Type Usage Guidelines
When to use int
When to use int
Use
int for:- Counting and indexing
- Whole number calculations
- Boolean-like flags (0 or 1)
- Results that don’t need decimal precision
When to use float
When to use float
Use
float for:- Scientific calculations
- Measurements requiring decimal precision
- Mathematical constants (like pi)
- Division results that need precision
When to use bool
When to use bool
Use
bool for:- Flags and state indicators
- Condition results
- True/false logic
- Control flow decisions