Function abs_sub

fn abs_sub(x: f32, other: f32) -> f32

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

Examples

#![feature(core_float_math)]

use core::f32;

let x = 3.0f32;
let y = -3.0f32;

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

assert!(abs_difference_x <= 1e-6);
assert!(abs_difference_y <= 1e-6);

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