Copy-paste fix pattern
library CB-Math
fn main() {
u256 coins = 10
u256 cost = 20
u256 safe = CB-Math.max(coins, cost) - cost
save safe
}
ClosedBit Docs
ClosedBit error docs
u256 underflow. A checked unsigned 256-bit subtraction or operation produced a negative result.
A checked unsigned 256-bit subtraction or operation produced a negative result.
Compare before subtracting, clamp to zero, or use a signed type when negative values are intentional.
library CB-Math
fn main() {
u256 coins = 10
u256 cost = 20
u256 safe = CB-Math.max(coins, cost) - cost
save safe
}