Function abs_sub

Deprecated since 1.10.0: you probably meant `(self - other).abs()`: this operation is `(self - other).max(0.0)` except that `abs_sub` also propagates NaNs (also known as `fdim` in C). If you truly need the positive difference, consider using that expression or the C function `fdim`, depending on how you wish to handle NaN (please consider filing an issue describing your use-case too).
#[must_use = "method returns a new number and does not mutate the original value"]
pub fn abs_sub(x: f64, other: f64) -> f64

Experimental version of abs_sub in core. See f64::abs_sub for details.

Examples

#![feature(core_float_math)]

use core::f64;

let x = 3.0_f64;
let y = -3.0_f64;

let abs_difference_x = (f64::math::abs_sub(x, 1.0) - 2.0).abs();
let abs_difference_y = (f64::math::abs_sub(y, 1.0) - 0.0).abs();

assert!(abs_difference_x < 1e-10);
assert!(abs_difference_y < 1e-10);

This standalone function is for testing only. It will be stabilized as an inherent method.