Initialise `sum = 0.0f` before adding to it. Otherwise it'll get not just a compiler warning, but also undefined behaviour.