GnuCash c935c2f+
Loading...
Searching...
No Matches
Functions
Gnc_numeric_comparison

Compare function. More...

Functions

int GncNumeric::cmp (GncNumeric b)
 
int GncNumeric::cmp (int64_t b)
 

Detailed Description

Compare function.

Parameters
bGncNumeric or int to compare to.
Returns
-1 if this < b, 0 if ==, 1 if this > b.

Function Documentation

◆ cmp() [1/2]

int GncNumeric::cmp ( GncNumeric  b)

Definition at line 607 of file gnc-numeric.cpp.

608{
609 if (m_den == b.denom())
610 {
611 auto b_num = b.num();
612 return m_num < b_num ? -1 : b_num < m_num ? 1 : 0;
613 }
614 GncRational an(*this), bn(b);
615 return an.cmp(bn);
616}
int64_t denom() const noexcept
Accessor for denominator value.
int64_t num() const noexcept
Accessor for numerator value.
Rational number class using GncInt128 for the numerator and denominator.

◆ cmp() [2/2]

int GncNumeric::cmp ( int64_t  b)
inline

Definition at line 266 of file gnc-numeric.hpp.

266{ return cmp(GncNumeric(b, 1)); }
GncNumeric()
Default constructor provides the zero value.