pub trait ArrayRounding<N: Numeric>{
// Required methods
fn round(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>;
fn around(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>;
fn rint(&self) -> Result<Array<N>, ArrayError>;
fn fix(&self) -> Result<Array<N>, ArrayError>;
fn trunc(&self) -> Result<Array<N>, ArrayError>;
fn floor(&self) -> Result<Array<N>, ArrayError>;
fn ceil(&self) -> Result<Array<N>, ArrayError>;
}
Expand description
ArrayTrait
- Array Rounding functions
Required Methods§
Sourcefn round(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>
fn round(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>
Evenly round to the given number of decimals
§Arguments
decimals
- Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point
§Examples
use arr_rs::prelude::*;
let arr = Array::flat(vec![2.01, 4.6, 8.0010, 22.234]);
assert_eq!(Array::flat(vec![2., 4.6, 8.001, 20.]), arr.round(&Array::flat(vec![0, 1, 3, -1]).unwrap()));
§Errors
may returns ArrayError
Sourcefn around(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>
fn around(&self, decimals: &Array<isize>) -> Result<Array<N>, ArrayError>
Evenly round to the given number of decimals. alias on round
§Arguments
decimals
- Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point
§Examples
use arr_rs::prelude::*;
let arr = Array::flat(vec![2.01, 4.6, 8.0010, 22.234]);
assert_eq!(Array::flat(vec![2., 4.6, 8.001, 20.]), arr.around(&Array::flat(vec![0, 1, 3, -1]).unwrap()));
§Errors
may returns ArrayError
Sourcefn rint(&self) -> Result<Array<N>, ArrayError>
fn rint(&self) -> Result<Array<N>, ArrayError>
Sourcefn fix(&self) -> Result<Array<N>, ArrayError>
fn fix(&self) -> Result<Array<N>, ArrayError>
Sourcefn trunc(&self) -> Result<Array<N>, ArrayError>
fn trunc(&self) -> Result<Array<N>, ArrayError>
Sourcefn floor(&self) -> Result<Array<N>, ArrayError>
fn floor(&self) -> Result<Array<N>, ArrayError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.