pub struct Fixed {
pub negative: bool,
pub magnitude: U256,
pub places: Places,
}Expand description
A fixed-point value: magnitude × 10^-places.dec, with the places it is declared to hold.
Fields§
§negative: bool§magnitude: U256§places: PlacesImplementations§
Source§impl Fixed
impl Fixed
pub fn new(value: i128, places: Places) -> Self
pub fn to_i128(self) -> Option<i128>
Sourcepub fn fit(self, to: Places) -> Self
pub fn fit(self, to: Places) -> Self
Keeps to.dec decimal places, truncating the rest, and to.int integer places, dropping
high-order digits.
pub fn add( self, other: Self, dmax: u32, arith: Arith, ) -> Result<Self, ArithError>
pub fn sub( self, other: Self, dmax: u32, arith: Arith, ) -> Result<Self, ArithError>
pub fn mul( self, other: Self, dmax: u32, arith: Arith, ) -> Result<Self, ArithError>
pub fn div( self, divisor: Self, dmax: u32, arith: Arith, ) -> Result<Self, ArithError>
Sourcepub fn to_receiver(self, places: Places, rounded: bool) -> (Self, bool)
pub fn to_receiver(self, places: Places, rounded: bool) -> (Self, bool)
The value a receiver of places gets: truncated, or rounded half away from zero, and whether
the integer part overflowed it (ON SIZE ERROR).
Trait Implementations§
impl Copy for Fixed
impl Eq for Fixed
impl StructuralPartialEq for Fixed
Auto Trait Implementations§
impl Freeze for Fixed
impl RefUnwindSafe for Fixed
impl Send for Fixed
impl Sync for Fixed
impl Unpin for Fixed
impl UnsafeUnpin for Fixed
impl UnwindSafe for Fixed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more