Use double instead of float in function calculation