转到uint8到float32

I'm trying to learn Go and working on a rain intensity tool. For this tool I have to make a calculation like this:

var intensity float32
intensity = 10^((value−109)÷32)

The value is an uint8, ranging from 0 to 255. The intensity variable is a float.

However, Go tells me that

cannot use 10 ^ (value - 109) / 32 (type uint8) as type float32 in assignment

How can I solve this?

  1. There is no ÷ operator in Go and ^ is a bitwise XOR, you need to use Pow functions from math package
  2. Go is very strict about type conversions, so it disallows implicit type conversions in many cases (so unsigned integer to floating point is not valid), so you need explicitly convert it with type(expr), i.e. float32(1)

That said:

intensity = float32(math.Pow(10, float64((value - 109) / 32)))
// - OR -
intensity = float32(math.Pow10(int((value - 109) / 32)))