I have Double
data type, cause I need result with floating number, but if my result is negative, it broke all my algorithm. Is there maybe a unsigned data type with floating point?
Use max
to limit numbers from going below zero:
let posOrZero = max(possiblyNegative, 0)
If possiblyNegative
is above zero, it's going to be the result of max
; Otherwise, zero is returned.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With