xur_

> built-in type

int

methods of int 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

# int.abs(x: i64) -> i64

The absolute value.

# int.max(x: i64, y: i64) -> i64

The larger of x and y.

# int.min(x: i64, y: i64) -> i64

The smaller of x and y.

# int.pow(x: i64, exp: u32) -> i64

x raised to the power exp.

# int.to_float(x: i64) -> f64

The value as a float. Integers beyond 2^53 lose precision.

# int.to_hex(x: i64) -> str

The value in lowercase hexadecimal without a 0x prefix: 255.to_hex() is "ff". A negative value is shown as its 64-bit two's complement: (-1).to_hex() is "ffffffffffffffff".

# int.to_string(x: i64) -> str

The value in decimal: "-42".

> examples

use std::io;

fn main() {
    io::println("{}", (-5).abs());
    io::println("{}", 255.to_hex());
    io::println("{}", 3.14.floor());
}