QOF  0.7.5
qofmath128.h
1 /********************************************************************
2  * qofmath128.h -- an 128-bit integer library *
3  * Copyright (C) 2004 Linas Vepstas <linas@linas.org> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22  *******************************************************************/
23 
24 #ifndef QOF_MATH_128_H
25 #define QOF_MATH_128_H
26 
27 #include <glib.h>
28 
38 typedef struct
39 {
40  guint64 hi;
41  guint64 lo;
42  gshort isneg;
43  gshort isbig;
44 } QofInt128;
45 
47 inline gboolean equal128 (QofInt128 a, QofInt128 b);
48 
50 inline gint cmp128 (QofInt128 a, QofInt128 b);
51 
53 inline QofInt128 shift128 (QofInt128 x);
54 
57 
59 inline QofInt128 inc128 (QofInt128 a);
60 
62 inline QofInt128 add128 (QofInt128 a, QofInt128 b);
63 
67 inline QofInt128 mult128 (gint64 a, gint64 b);
68 
72 inline QofInt128 div128 (QofInt128 n, gint64 d);
73 
79 inline gint64 rem128 (QofInt128 n, gint64 d);
80 
82 inline guint64 gcf64 (guint64 num, guint64 denom);
83 
85 inline QofInt128 lcm128 (guint64 a, guint64 b);
86 
89 #endif