Types, Numbers & Physical Units
Numeric widths, decimal rounding rules, and measurement dimensions are explicit in Myceta's type system so physical and financial calculations never silently lose units or precision.
1. Scalar & Container Carriers
| Category | Carriers | Notes |
|---|---|---|
| Signed integers | i8, i16, i32, i64, bigint | Unsuffixed integer literals default to i64; arbitrary-precision literals use suffix n (e.g., 42n). |
| Unsigned integers | u8, u16, u32, u64 | Explicit width suffix when uncontextualized (e.g., 255u8). |
| IEEE-754 floating-point | f32, f64 | Unsuffixed decimal literals default to f64; grouping underscores allowed (1_000_000). |
| Structured containers | array<T>, vector<T>, matrix<T>, tensor<T>, optional<T> | Expected container element types propagate bidirectionally into array literals, if arms, and match branches. |
2. Literal Exactness & Lossy-Cast Policy
Integer and decimal source text denote exact mathematical values prior to carrier materialization. Decimal text targeting
f64 uses IEEE-754 round-to-nearest-even; narrowing conversions (such as decimal-to-f32, integer-to-float,
or narrowing integer casts) are governed per module by numeric.lossy_cast_policy (allow, warn, or deny):
directives {
numeric.lossy_cast_policy = deny
}
let samples: array<i32> = [10, 20, 30] // element type flows cleanly into literals
let exactBig = 900719925474099312345n // arbitrary-precision bigint
3. Unit-Parameterized Types & Quantities
Any numeric width may be parameterized by an algebraic unit expression width<U> (or marked explicitly
dimensionless via width<>). Multiplication and division compose unit exponents algebraically; addition,
subtraction, and comparison require identical canonical dimensions:
import Myceta.Units.SI
quantity Pressure = Mass / (Length * Time^2)
fn axialStress(force: f64<N>, area: f64<m^2>) -> f64<Pa> =
force / area
node ColumnStress: f64<Pa> = axialStress(450_000.0<N>, 0.018<m^2>)
node SafetyFactor: f64<> = 250_000_000.0<Pa> / ColumnStress