pub struct Numeric(/* private fields */);Expand description
A rational number with 64-bit numerator and denominator.
Used for precise financial calculations without floating-point rounding errors.
§Examples
use gnucash_sys::Numeric;
// Create $100.00 (10000 cents / 100)
let amount = Numeric::new(10000, 100);
assert_eq!(amount.to_f64(), 100.0);
// Create from integer
let whole: Numeric = 42i64.into();
assert_eq!(whole.num(), 42);
assert_eq!(whole.denom(), 1);
// Negate a value
let neg = -amount;
assert!(neg.is_negative());Implementations§
Source§impl Numeric
impl Numeric
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Checks if this value is negative.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Checks if this value is positive.
Trait Implementations§
Source§impl From<Numeric> for gnc_numeric
impl From<Numeric> for gnc_numeric
Source§impl From<_gnc_numeric> for Numeric
impl From<_gnc_numeric> for Numeric
Source§fn from(n: gnc_numeric) -> Self
fn from(n: gnc_numeric) -> Self
Converts to this type from the input type.
impl Copy for Numeric
impl Eq for Numeric
impl StructuralPartialEq for Numeric
Auto Trait Implementations§
impl Freeze for Numeric
impl RefUnwindSafe for Numeric
impl Send for Numeric
impl Sync for Numeric
impl Unpin for Numeric
impl UnwindSafe for Numeric
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