1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4maadu.ctr
12 */
13 
14 #ifndef DK4MAADU_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4MAADU_H_INCLUDED 1
17 
18 
19 /**	@file
20 	Arithmetic operations on dk4_um_t.
21 
22 	CRT on Windows: Optional.
23 */
24 
25 #ifndef DK4CONF_H_INCLUDED
26 #if DK4_BUILDING_DKTOOLS4
27 #include "dk4conf.h"
28 #else
29 #include <dktools-4/dk4conf.h>
30 #endif
31 #endif
32 
33 #ifndef DK4TYPES_H_INCLUDED
34 #if DK4_BUILDING_DKTOOLS4
35 #include <libdk4base/dk4types.h>
36 #else
37 #include <dktools-4/dk4types.h>
38 #endif
39 #endif
40 
41 #ifndef DK4ERROR_H_INCLUDED
42 #if DK4_BUILDING_DKTOOLS4
43 #include <libdk4base/dk4error.h>
44 #else
45 #include <dktools-4/dk4error.h>
46 #endif
47 #endif
48 
49 
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
55 /**	Addition.
56         @param	a	Left operand.
57         @param	b	Right operand.
58         @param	erp	Error report, may be NULL.
59         @return	Result on success, least significant result bits
60         on overflow (see ec component of erp).
61 
62 	Error codes: DK4_E_OVERFLOW.
63 */
64 dk4_um_t
65 dk4ma_um_add(dk4_um_t a, dk4_um_t b, dk4_er_t *erp);
66 
67 /**	Subtraction.
68         @param	a	Left operand.
69         @param	b	Right operand.
70         @param	erp	Error report, may be NULL.
71         @return	Result on success, least significant result bits
72         on overflow (see ec component of erp).
73 
74 	Error codes: DK4_E_OVERFLOW.
75 */
76 dk4_um_t
77 dk4ma_um_sub(dk4_um_t a, dk4_um_t b, dk4_er_t *erp);
78 
79 /**	Multiplication.
80         @param	a	Left factor.
81         @param	b	right factor.
82         @param	erp	Error report, may be NULL.
83         @return	Result on success, least significant
84         bits on overflow (see ec component of erp).
85 
86 	Error codes: DK4_E_OVERFLOW.
87 */
88 dk4_um_t
89 dk4ma_um_mul(dk4_um_t a, dk4_um_t b, dk4_er_t *erp);
90 
91 /**	Division.
92         @param	a	Counter (left operand).
93         @param	b	Denominator (right operand).
94         @param	erp	Error report, may be NULL.
95         @return	Division result on success,
96         DK4_UM_MAX on division by zero
97         (see the ec component of erp).
98 
99 	Error codes: DK4_E_DIVZERO.
100 */
101 dk4_um_t
102 dk4ma_um_div(dk4_um_t a, dk4_um_t b, dk4_er_t *erp);
103 
104 /**	Calculate greatest common divisor of two numbers.
105 	@param	a	One number.
106 	@param	b	Other number.
107 	@return	Greatest common divisor.
108 */
109 dk4_um_t
110 dk4ma_um_gcd(dk4_um_t a, dk4_um_t b);
111 
112 /**	Calculate least common multiple of two numbers.
113 	@param	a	One number.
114 	@param	b	Other number.
115 	@param	erp	Error report, may be NULL.
116 	@return	Least common multiple of a and b.
117 
118 	Error codes: DK4_E_OVERFLOW, DK4_E_DIVZERO.
119 */
120 dk4_um_t
121 dk4ma_um_lcm(dk4_um_t a, dk4_um_t b, dk4_er_t *erp);
122 
123 /**	Comparison: Is a greater than b.
124 	@param	a	Left comparison operand.
125 	@param	b	Right comparison operand.
126 	@return	1 if a>b, 0 otherwise.
127 */
128 int
129 dk4ma_um_isgr(dk4_um_t a, dk4_um_t b);
130 
131 /**	Comparison: Is a greater than or equal to b.
132 	@param	a	Left comparison operand.
133 	@param	b	Right comparison operand.
134 	@return	1 if a>=b, 0 otherwise.
135 */
136 int
137 dk4ma_um_isgeq(dk4_um_t a, dk4_um_t b);
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 
144 
145 #endif
146