mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add function to compare (order) two numbers
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@10152 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2e0ea64b27
commit
5ff6c419d6
@ -231,6 +231,28 @@ equal128 (qofint128 a, qofint128 b)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Return returns 1 if a>b, -1 if b>a, 0 if a == b */
|
||||
inline int
|
||||
cmp128 (qofint128 a, qofint128 b)
|
||||
{
|
||||
if ((0 == a.isneg) && b.isneg) return 1;
|
||||
if (a.isneg && (0 == b.isneg)) return -1;
|
||||
if (0 == a.isneg)
|
||||
{
|
||||
if (a.hi > b.hi) return 1;
|
||||
if (a.hi < b.hi) return -1;
|
||||
if (a.lo > b.lo) return 1;
|
||||
if (a.lo < b.lo) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a.hi > b.hi) return -1;
|
||||
if (a.hi < b.hi) return 1;
|
||||
if (a.lo > b.lo) return -1;
|
||||
if (a.lo < b.lo) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Return the greatest common factor of two 64-bit numbers */
|
||||
inline guint64
|
||||
gcf64(guint64 num, guint64 denom)
|
||||
|
@ -42,6 +42,9 @@ typedef struct {
|
||||
/** Return true of two numbers are equal */
|
||||
inline gboolean equal128 (qofint128 a, qofint128 b);
|
||||
|
||||
/** Return returns 1 if a>b, -1 if b>a, 0 if a == b */
|
||||
inline int cmp128 (qofint128 a, qofint128 b);
|
||||
|
||||
/** Shift right by one bit (i.e. divide by two) */
|
||||
inline qofint128 shift128 (qofint128 x);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user