fix bit shifts in energy sum calculation