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
| Member | Description | Available through |
|---|---|---|
| Debug | Produces an unambiguous structural representation of a value. | |
| Signed | Identifies signed numeric types. |
Implemented by
| Member | Description | Available through |
|---|---|---|
| f32 | Stores a 32-bit floating-point number. | |
| f64 | Stores a 64-bit floating-point number. |
Methods
| Member | Description | Available through |
|---|---|---|
| ceil | Rounds up to the nearest integral value. | |
| floor | Rounds down to the nearest integral value. | |
| isFinite | Returns whether the receiver is neither infinity nor NaN. | |
| isNaN | Returns whether the receiver is the floating-point not-a-number value. | |
| round | Rounds to the nearest integral value, with halfway values rounded to even. | |
| roundTo | Rounds to a requested number of digits after the decimal point. | |
| sqrt | Returns the principal square root of this value. | |
| truncate | Rounds this value toward zero to an integral value. |