Copy-paste fix pattern
library CB-Math
fn main() {
u256 health = 20
u256 damage = 50
u256 safeHealth = CB-Math.max(health - CB-Math.min(health, damage), zero)
save safeHealth
}
ClosedBit Docs
ClosedBit error docs
Numeric underflow. A checked unsigned operation produced a value below zero.
A checked unsigned operation produced a value below zero.
Compare before subtracting, clamp to zero, or use a signed type when negative values are intended.
library CB-Math
fn main() {
u256 health = 20
u256 damage = 50
u256 safeHealth = CB-Math.max(health - CB-Math.min(health, damage), zero)
save safeHealth
}