• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4829

30 Oct 2025 09:25AM UTC coverage: 49.734% (-11.3%) from 61.071%
#4829

push

travis-ci

web-flow
Merge pull request #33435 from taosdata/3.0

merge 3.0

123072 of 323930 branches covered (37.99%)

Branch coverage included in aggregate %.

7 of 25 new or added lines in 3 files covered. (28.0%)

35232 existing lines in 327 files now uncovered.

172062 of 269495 relevant lines covered (63.85%)

70709785.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.49
/source/libs/decimal/src/detail/wideInteger.cpp
1
#include "wideInteger.h"
2
#include "intx/int128.hpp"
3
#include "intx/intx.hpp"
4

5

6
const UInt128  uInt128Zero = {0, 0};
7
const uint64_t k1e18 = 1000000000000000000LL;
8
const UInt128  uInt128_1e18 = {k1e18, 0};
9
const UInt128 uInt128One = {1, 0};
10
const UInt128 uInt128Two = {2, 0};
11

12
void makeUInt128(uint128* pUint128, uint64_t high, uint64_t low) {
2,147,483,647✔
13
  intx::uint128* pIntxUint = (intx::uint128*)pUint128;
2,147,483,647✔
14
  pIntxUint->hi = high;
2,147,483,647✔
15
  pIntxUint->lo = low;
2,147,483,647✔
16
}
2,147,483,647✔
17

18
uint64_t uInt128Hi(const UInt128* pInt) {
1,649,627,081✔
19
  intx::uint128 *pIntUint = (intx::uint128*)pInt;
1,649,627,081✔
20
  return pIntUint->hi;
1,649,627,081✔
21
}
22

23
uint64_t uInt128Lo(const UInt128* pInt) {
2,147,483,647✔
24
  intx::uint128 *pIntUint = (intx::uint128*)pInt;
2,147,483,647✔
25
  return pIntUint->lo;
2,147,483,647✔
26
}
27

28
void uInt128Add(UInt128* pLeft, const UInt128* pRight) {
×
29
  intx::uint128 *pX = (intx::uint128*)pLeft;
×
30
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
31
  *pX += *pY;
×
32
}
×
33
void uInt128Subtract(UInt128* pLeft, const UInt128* pRight) {
×
34
  intx::uint128 *pX = (intx::uint128*)pLeft;
×
35
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
36
  *pX -= *pY;
×
37
}
×
38
void uInt128Multiply(UInt128* pLeft, const UInt128* pRight) {
1,054,275,842✔
39
  intx::uint128 *pX = (intx::uint128*)pLeft;
1,054,275,842✔
40
  const intx::uint128 *pY = (const intx::uint128*)pRight;
1,054,275,842✔
41
  *pX *= *pY;
1,054,275,842✔
42
  /* __uint128_t *px = (__uint128_t*)pLeft;
43
  const __uint128_t *py = (__uint128_t*)pRight;
44
  *px = *px * *py; */
45
}
1,054,285,228✔
46
void uInt128Divide(UInt128* pLeft, const UInt128* pRight) {
577,292,827✔
47
  intx::uint128 *pX = (intx::uint128*)pLeft;
577,292,827✔
48
  const intx::uint128 *pY = (const intx::uint128*)pRight;
577,292,827✔
49
  *pX /= *pY;
577,292,827✔
50
  /* __uint128_t *px = (__uint128_t*)pLeft;
51
  const __uint128_t *py = (__uint128_t*)pRight;
52
  *px = *px / *py; */
53
}
577,292,827✔
54
void uInt128Mod(UInt128* pLeft, const UInt128* pRight) {
577,292,827✔
55
  intx::uint128 *pX = (intx::uint128*)pLeft;
577,292,827✔
56
  const intx::uint128 *pY = (const intx::uint128*)pRight;
577,292,827✔
57
  *pX %= *pY;
577,292,827✔
58
  /* __uint128_t *px = (__uint128_t*)pLeft;
59
  const __uint128_t *py = (__uint128_t*)pRight;
60
  *px = *px % *py; */
61
}
577,292,827✔
UNCOV
62
bool uInt128Lt(const UInt128* pLeft, const UInt128* pRight) {
×
UNCOV
63
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
×
UNCOV
64
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
UNCOV
65
  return *pX < *pY;
×
66
}
67
bool uInt128Gt(const UInt128* pLeft, const UInt128* pRight) {
×
68
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
×
69
  const intx::uint128 *pY = (const intx::uint128*)pRight;
×
70
  return *pX > *pY;
×
71
}
72
bool uInt128Eq(const UInt128* pLeft, const UInt128* pRight) {
933,208,292✔
73
  const intx::uint128 *pX = (const intx::uint128*)pLeft;
933,208,292✔
74
  const intx::uint128 *pY = (const intx::uint128*)pRight;
933,208,292✔
75
  return *pX == *pY;
933,208,292✔
76
}
77

78
Int128 makeInt128(int64_t high, uint64_t low) {
×
79
  Int128 int128 = {low, high};
×
80
  return int128;
×
81
}
82
int64_t int128Hi(const Int128* pUint128) {
×
83
  return pUint128->high;
×
84
}
85
uint64_t int128Lo(const Int128* pUint128) {
×
86
  return pUint128->low;
×
87
}
88
Int128 int128Abs(const Int128* pInt128) {
×
89
  if (int128Lt(pInt128, &int128Zero)) {
×
90
    return int128Negate(pInt128);
×
91
  }
92
  return *pInt128;
×
93
}
94
Int128 int128Negate(const Int128* pInt128) {
×
95
  uint64_t low = ~pInt128->low + 1;
×
96
  int64_t  high = ~pInt128->high;
×
97
  if (low == 0) high += 1;
×
98
  return makeInt128(high, low);
×
99
}
100
Int128 int128Add(const Int128* pLeft, const Int128* pRight) {
×
101
  intx::uint128 result = *(intx::uint128*)pLeft + *(intx::uint128*)pRight;
×
102
  return *(Int128*)&result;
×
103
}
104
Int128 int128Subtract(const Int128* pLeft, const Int128* pRight) {
×
105
  intx::uint128 result = *(intx::uint128*)pLeft - *(intx::uint128*)pRight;
×
106
  return *(Int128*)&result;
×
107
}
108
Int128 int128Multiply(const Int128* pLeft, const Int128* pRight) {
×
109
  intx::uint128 result = *(intx::uint128*)pLeft * *(intx::uint128*)pRight;
×
110
  return *(Int128*)&result;
×
111
}
112
Int128 int128Divide(const Int128* pLeft, const Int128* pRight) {
×
113
  intx::uint128 result = *(intx::uint128*)pLeft / *(intx::uint128*)pRight;
×
114
  return *(Int128*)&result;
×
115
}
116
Int128 int128Mod(const Int128* pLeft, const Int128* pRight) {
×
117
  intx::uint128 result = *(intx::uint128*)pLeft % *(intx::uint128*)pRight;
×
118
  return *(Int128*)&result;
×
119
}
UNCOV
120
bool int128Lt(const Int128* pLeft, const Int128* pRight) {
×
UNCOV
121
  return pLeft->high < pRight->high || (pLeft->high == pRight->high && pLeft->low < pRight->low);
×
122
}
123
bool int128Gt(const Int128* pLeft, const Int128* pRight) {
×
124
  return int128Lt(pRight, pLeft);
×
125
}
UNCOV
126
bool int128Eq(const Int128* pLeft, const Int128* pRight) {
×
UNCOV
127
  return pLeft->high == pRight->high && pLeft->low == pRight->low;
×
128
}
129
Int128 int128RightShift(const Int128* pLeft, int32_t shift) {
×
130
  intx::uint128 result = *(intx::uint128*)pLeft >> shift;
×
131
  return *(Int128*)&result;
×
132
}
133

134
const Int128 int128Zero = {0, 0};
135
const Int128 int128One = {1, 0};
136

137
UInt256 makeUint256(UInt128 high, UInt128 low) {
×
138
  UInt256 uint256 = {high, low};
×
139
  return uint256;
×
140
}
141
uint128 uInt256Hi(const UInt256* pUint256) {
×
142
  return pUint256->high;
×
143
}
144
uint128 uInt256Lo(const UInt256* pUint256) {
×
145
  return pUint256->low;
×
146
}
147
UInt256 uInt256Add(const UInt256* pLeft, const UInt256* pRight) {
×
148
  intx::uint256 result = *(intx::uint256*)pLeft + *(intx::uint256*)pRight;
×
149
  return *(UInt256*)&result;
×
150
}
151
UInt256 uInt256Subtract(const UInt256* pLeft, const UInt256* pRight) {
×
152
  intx::uint256 result = *(intx::uint256*)pLeft - *(intx::uint256*)pRight;
×
153
  return *(UInt256*)&result;
×
154
}
155
UInt256 uInt256Multiply(const UInt256* pLeft, const UInt256* pRight) {
×
156
  intx::uint256 result = *(intx::uint256*)pLeft * *(intx::uint256*)pRight;
×
157
  return *(UInt256*)&result;
×
158
}
159
UInt256 uInt256Divide(const UInt256* pLeft, const UInt256* pRight) {
×
160
  intx::uint256 result = *(intx::uint256*)pLeft / *(intx::uint256*)pRight;
×
161
  return *(UInt256*)&result;
×
162
}
163
UInt256 uInt256Mod(const UInt256* pLeft, const UInt256* pRight) {
×
164
  intx::uint256 result = *(intx::uint256*)pLeft % *(intx::uint256*)pRight;
×
165
  return *(UInt256*)&result;
×
166
}
167
bool uInt256Lt(const UInt256* pLeft, const UInt256* pRight) {
×
168
  return *(intx::uint256*)pLeft < *(intx::uint256*)pRight;
×
169
}
170
bool uInt256Gt(const UInt256* pLeft, const UInt256* pRight) {
×
171
  return *(intx::uint256*)pLeft > *(intx::uint256*)pRight;
×
172
}
173
bool uInt256Eq(const UInt256* pLeft, const UInt256* pRight) {
×
174
  return *(intx::uint256*)pLeft == *(intx::uint256*)pRight;
×
175
}
176
UInt256 uInt256RightShift(const UInt256* pLeft, int32_t shift) {
×
177
  intx::uint256 result = *(intx::uint256*)pLeft >> shift;
×
178
  return *(UInt256*)&result;
×
179
}
180

UNCOV
181
Int256 makeInt256(Int128 high, UInt128 low) {
×
UNCOV
182
  Int256 int256 = {low, high};
×
UNCOV
183
  return int256;
×
184
}
UNCOV
185
Int128 int256Hi(const Int256* pUint256) {
×
UNCOV
186
  return pUint256->high;
×
187
}
UNCOV
188
UInt128 int256Lo(const Int256* pUint256) {
×
UNCOV
189
  return pUint256->low;
×
190
}
UNCOV
191
Int256 int256Abs(const Int256* pInt256) {
×
UNCOV
192
  if (int256Lt(pInt256, &int256Zero)) {
×
193
    return int256Negate(pInt256);
×
194
  }
UNCOV
195
  return *pInt256;
×
196
}
197

198
Int256 int256Negate(const Int256* pInt256) {
×
199
  return int256Subtract(&int256Zero, pInt256);
×
200
}
UNCOV
201
Int256 int256Add(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
202
  intx::uint256 result = *(intx::uint256*)pLeft + *(intx::uint256*)pRight;
×
UNCOV
203
  return *(Int256*)&result;
×
204
}
205
Int256 int256Subtract(const Int256* pLeft, const Int256* pRight) {
×
206
  intx::uint256 result = *(intx::uint256*)pLeft - *(intx::uint256*)pRight;
×
207
  return *(Int256*)&result;
×
208
}
UNCOV
209
Int256 int256Multiply(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
210
  intx::uint256 result = *(intx::uint256*)pLeft * *(intx::uint256*)pRight;
×
UNCOV
211
  return *(Int256*)&result;
×
212
}
UNCOV
213
Int256 int256Divide(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
214
  Int256 l = *pLeft, r = *pRight;
×
UNCOV
215
  bool   leftNegative = int256Lt(pLeft, &int256Zero), rightNegative = int256Lt(pRight, &int256Zero);
×
UNCOV
216
  if (leftNegative) {
×
217
    l = int256Abs(pLeft);
×
218
  }
UNCOV
219
  if (rightNegative) {
×
220
    r = int256Abs(pRight);
×
221
  }
UNCOV
222
  intx::uint256 result = *(intx::uint256*)&l / *(intx::uint256*)&r;
×
UNCOV
223
  Int256 res =  *(Int256*)&result;
×
UNCOV
224
  if (leftNegative != rightNegative)
×
225
    res = int256Negate(&res);
×
UNCOV
226
  return res;
×
227
}
228

UNCOV
229
Int256 int256Mod(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
230
  Int256 left = *pLeft, right = *pRight;
×
UNCOV
231
  bool leftNegative = int256Lt(pLeft, &int256Zero);
×
UNCOV
232
  if (leftNegative) {
×
233
    left = int256Abs(&left);
×
234
  }
UNCOV
235
  bool rightNegate = int256Lt(pRight, &int256Zero);
×
UNCOV
236
  if (rightNegate) right = int256Abs(pRight);
×
UNCOV
237
  intx::uint256 result = *(intx::uint256*)&left % *(intx::uint256*)&right;
×
UNCOV
238
  Int256 res =  *(Int256*)&result;
×
UNCOV
239
  if (leftNegative) res = int256Negate(&res);
×
UNCOV
240
  return res;
×
241
}
UNCOV
242
bool int256Lt(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
243
  Int128  hiLeft = int256Hi(pLeft), hiRight = int256Hi(pRight);
×
UNCOV
244
  UInt128 lowLeft = int256Lo(pLeft), lowRight = int256Lo(pRight);
×
UNCOV
245
  return int128Lt(&hiLeft, &hiRight) || (int128Eq(&hiLeft, &hiRight) && uInt128Lt(&lowLeft, &lowRight));
×
246
}
UNCOV
247
bool int256Gt(const Int256* pLeft, const Int256* pRight) {
×
UNCOV
248
  return int256Lt(pRight, pLeft);
×
249
}
250
bool int256Eq(const Int256* pLeft, const Int256* pRight) {
×
251
  Int128  hiLeft = int256Hi(pLeft), hiRight = int256Hi(pRight);
×
252
  UInt128 lowLeft = int256Lo(pLeft), lowRight = int256Lo(pRight);
×
253
  return int128Eq(&hiLeft, &hiRight) && uInt128Eq(&lowLeft, &lowRight);
×
254
}
UNCOV
255
Int256 int256RightShift(const Int256* pLeft, int32_t shift) {
×
UNCOV
256
  intx::uint256 result = *(intx::uint256*)pLeft >> shift;
×
UNCOV
257
  return *(Int256*)&result;
×
258
}
259

260
const Int256 int256One = {uInt128One, int128Zero};
261
const Int256 int256Zero = {uInt128Zero, int128Zero};
262
const Int256 int256Two = {uInt128Two, int128Zero};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc