Numeric Methods
Methods available on Int and Float types.
Integer Methods
toFloat
Converts the integer to a floating-point number.
strata
fn toFloat(): Floatstrata
let count = 10;
let floatCount = count.toFloat(); // 10.0toString
Converts the integer to a string representation.
strata
fn toString(): Stringstrata
let answer = 42;
let answerString = answer.toString(); // "42"abs
Returns the absolute value.
strata
fn abs(): Intstrata
let temperature = -5;
print(temperature.abs()); // 5Float Methods
toInt
Converts the float to an integer by truncating the decimal part.
strata
fn toInt(): Intstrata
let price = 3.99;
let basePrice = price.toInt(); // 3toString
Converts the float to a string representation.
strata
fn toString(): Stringstrata
let pi = 3.14;
print(pi.toString()); // "3.14"round
Rounds the float to the specified number of decimal places.
strata
fn round(precision: Int): Floatstrata
let pi = 3.14159;
print(pi.round(precision: 2)); // 3.14floor
Rounds down to the nearest integer.
strata
fn floor(): Floatstrata
let rating = 3.9;
print(rating.floor()); // 3.0ceil
Rounds up to the nearest integer.
strata
fn ceil(): Floatstrata
let progress = 3.1;
print(progress.ceil()); // 4.0