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: dk4maaus.ctr 12 */ 13 14 #ifndef DK4MAAUS_H_INCLUDED 15 /** Avoid multiple inclusions. */ 16 #define DK4MAAUS_H_INCLUDED 1 17 18 19 /** @file 20 Arithmetic operations on unsigned short. 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 unsigned short 65 dk4ma_ushort_add(unsigned short a, unsigned short 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 unsigned short 77 dk4ma_ushort_sub(unsigned short a, unsigned short 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 unsigned short 89 dk4ma_ushort_mul(unsigned short a, unsigned short 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 USHRT_MAX on division by zero 97 (see the ec component of erp). 98 99 Error codes: DK4_E_MATH_DIVZERO. 100 */ 101 unsigned short 102 dk4ma_ushort_div(unsigned short a, unsigned short b, dk4_er_t *erp); 103 104 /** Convert dk4_um_t value to unsigned short. 105 @param u Value to convert. 106 @param erp Error report, may be NULL. 107 @return Conversion result. 108 109 Error codes: DK4_E_MATH_OVERFLOW. 110 */ 111 unsigned short 112 dk4ma_ushort_from(dk4_um_t u, dk4_er_t *erp); 113 114 /** Convert double to signed char. 115 @param d Value to convert. 116 @param erp Error report, may be NULL. 117 @return Conversion result. 118 119 Error codes: DK4_E_OVERFLOW. 120 */ 121 unsigned short 122 dk4ma_ushort_from_double(double d, dk4_er_t *erp); 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 129 130 #endif 131