MCPcopy Create free account
hub / github.com/ElementsProject/elements / bounded_add

Function bounded_add

src/simplicity/bounded.h:15–19  ·  view source on GitHub ↗

Returns min(x + y, UBOUNDED_MAX) */

Source from the content-addressed store, hash-verified

13
14/* Returns min(x + y, UBOUNDED_MAX) */
15static inline ubounded bounded_add(ubounded x, ubounded y) {
16 return UBOUNDED_MAX < x ? UBOUNDED_MAX
17 : UBOUNDED_MAX - x < y ? UBOUNDED_MAX
18 : x + y;
19}
20
21/* *x = min(*x + 1, UBOUNDED_MAX) */
22static inline void bounded_inc(ubounded* x) {

Callers 2

simplicity_analyseBoundsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected