go-imgrow/inversescale.go

16 lines
286 B
Go
Raw Normal View History

2024-02-09 19:10:11 +00:00
package imgrow
// inverseScale basically does:
//
// return n / scalar
//
// ... except, that it deals with the case where 0 == scalar in a special way.
func inverseScale(scalar int, n int) int {
switch {
case 0 == scalar:
return divideByZero(n)
default:
return n / scalar
}
}