Module shr

Module shr 

Source
Expand description

Right-shifting a Float (dividing it by a power of 2).

§shr

use malachite_base::num::basic::traits::{Infinity, Zero};
use malachite_float::Float;

assert_eq!(Float::ZERO >> 10, 0);
assert_eq!(Float::INFINITY >> 10, Float::INFINITY);
assert_eq!(
    (Float::from(std::f64::consts::PI) >> 10u8).to_string(),
    "0.003067961575771282"
);
assert_eq!(
    (Float::from(std::f64::consts::PI) >> -10i8).to_string(),
    "3216.990877275948"
);

assert_eq!(&Float::ZERO >> 10, 0);
assert_eq!(&Float::INFINITY >> 10, Float::INFINITY);
assert_eq!(
    (&Float::from(std::f64::consts::PI) >> 10u8).to_string(),
    "0.003067961575771282"
);
assert_eq!(
    (&Float::from(std::f64::consts::PI) >> -10i8).to_string(),
    "3216.990877275948"
);

§shr_assign

use malachite_base::num::basic::traits::{Infinity, Zero};
use malachite_float::Float;

let mut x = Float::ZERO;
x >>= 10;
assert_eq!(x, 0);

let mut x = Float::INFINITY;
x >>= 10;
assert_eq!(x, Float::INFINITY);

let mut x = Float::from(std::f64::consts::PI);
x >>= 10;
assert_eq!(x.to_string(), "0.003067961575771282");

let mut x = Float::from(std::f64::consts::PI);
x >>= -10;
assert_eq!(x.to_string(), "3216.990877275948");