pub fn sign<T>(x: T) -> T where
    T: FixedSigned
Expand description

Get the sign of the argument with a unit value. Zero is of positive sign.

Arguments

  • x - The function argument.

Example

use fixed_trigonometry::*;
use fixed::{types::extra::U22, FixedI32};
 
let mut x = FixedI32::<U22>::from_num(-0.2);
let mut y = sign(x);
assert_eq!{ y.to_num::<f32>(), -1.0 };
 
x = FixedI32::<U22>::from_num(0.2);
y = sign(x); 
assert_eq!{ y.to_num::<f32>(), 1.0 };