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: dk4maami.ctr 12 */ 13 14 #ifndef DK4MAAMI_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4MAAMI_H_INCLUDED 1 17 18 19 /** @file 20 Arithmetic operations on intmax_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 #if DK4_HAVE_INTMAX_T 56 57 /** Absolute value. 58 @param a Operand. 59 @param erp Error report, may be NULL. 60 @return Result on success, INTMAX_MAX if a is INTMAX_MIN 61 (overflow is reported in erp). 62 63 Error codes: DK4_E_OVERFLOW. 64 */ 65 intmax_t 66 dk4ma_intmax_t_abs(intmax_t a, dk4_er_t *erp); 67 68 /** Addition. 69 @param a Left operand. 70 @param b Right operand. 71 @param erp Error report, may be NULL. 72 @return Result on success, least significant result bits 73 on overflow (see ec component of erp). 74 75 Error codes: DK4_E_OVERFLOW. 76 */ 77 intmax_t 78 dk4ma_intmax_t_add(intmax_t a, intmax_t b, dk4_er_t *erp); 79 80 /** Subtraction. 81 @param a Left operand. 82 @param b Right operand. 83 @param erp Error report, may be NULL. 84 @return Result on success, least significant result bits 85 on overflow (see ec component of erp). 86 87 Error codes: DK4_E_OVERFLOW. 88 */ 89 intmax_t 90 dk4ma_intmax_t_sub(intmax_t a, intmax_t b, dk4_er_t *erp); 91 92 /** Multiplication. 93 @param a Left factor. 94 @param b right factor. 95 @param erp Error report, may be NULL. 96 @return Result on success, least significant 97 bits on overflow (see ec component of erp). 98 99 Error codes: DK4_E_OVERFLOW. 100 */ 101 intmax_t 102 dk4ma_intmax_t_mul(intmax_t a, intmax_t b, dk4_er_t *erp); 103 104 /** Division. 105 @param a Counter (left operand). 106 @param b Denominator (right operand). 107 @param erp Error report, may be NULL. 108 @return Division result on success, 109 INTMAX_MIN, INTMAX_MAX, or 0 on division by zero or overflow 110 (see the ec component of erp). 111 112 Error codes: DK4_E_OVERFLOW, DK4_E_DIVZERO. 113 */ 114 intmax_t 115 dk4ma_intmax_t_div(intmax_t a, intmax_t b, dk4_er_t *erp); 116 117 #endif 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 124 125 #endif 126