Fix a subtle floating point bug