19 lines
320 B
Go
19 lines
320 B
Go
package util
|
|
|
|
// AbsMinusd returns the value, with the absolute value subtracted
|
|
// by minus, or 0 if minus is more than abs.
|
|
func AbsMinusd(val, minus float64) float64 {
|
|
if val > 0 {
|
|
val -= minus
|
|
if val < 0 {
|
|
val = 0
|
|
}
|
|
} else {
|
|
val += minus
|
|
if val > 0 {
|
|
val = 0
|
|
}
|
|
}
|
|
return val
|
|
}
|