The FloatingPoint
protocol *does* work with integer literals though, so once you take care of pow
then you can write:
func srgb2linear<T: FloatingPoint> (_ s: T) -> T {
if s <= (4045/100_000) { // compare to 0.04045
return s * (100/1292) // divide by 12.92
} else {
return pow((s + 55/1000) * (1000/1055), 24/10)
// return pow((s + 0.055) / 1.055, 2.4)
}
}