> built-in type
float
methods of float values
in the browser
These are methods on integer and float values, available directly without importing a module. In each signature x is the value the method is called on: 3.min(5) calls min with x = 3 and y = 5. Wrap a negative literal in parentheses to call a method on it: (-5).abs().
Integer methods work on 64-bit signed values. A result that doesn't fit, such as 2.pow(70) or abs of the smallest i64, is a runtime error.
> methods
The nearest whole number, rounding halves away from zero: 2.5.round() is 3 and (-2.5).round() is -3.
The value as an integer, dropping the fraction (toward zero). Values beyond the i64 range give the largest or smallest i64, and NaN gives 0.
> examples
use std::io;
fn main() {
io::println("{}", (-5).abs());
io::println("{}", 255.to_hex());
io::println("{}", 3.14.floor());
}