SplitScript reference / Float

Float

capability

capability Float

Identifies floating-point types.

Floating-point constraints accept f32 and f64 values and imply signed numeric behavior together with Debug and Display. Their default text is the shortest correctly rounded decimal that parses back to the original value. Signed zero remains visible, and non-finite values use NaN, inf, and -inf.

Examples

Round a floating-point value

let nearest = 2.5.round()
let text = nearest as String

Requires

MemberDescriptionAvailable through
DebugProduces an unambiguous structural representation of a value.
SignedIdentifies signed numeric types.

Implemented by

MemberDescriptionAvailable through
f32Stores a 32-bit floating-point number.
f64Stores a 64-bit floating-point number.

Methods

MemberDescriptionAvailable through
ceilRounds up to the nearest integral value.
floorRounds down to the nearest integral value.
isFiniteReturns whether the receiver is neither infinity nor NaN.
isNaNReturns whether the receiver is the floating-point not-a-number value.
roundRounds to the nearest integral value, with halfway values rounded to even.
roundToRounds to a requested number of digits after the decimal point.
sqrtReturns the principal square root of this value.
truncateRounds this value toward zero to an integral value.