在阅读有关 location 的 Android 开发人员博客文章时,我遇到了这段代码(从博客中剪切和粘贴):
List<String> matchingProviders = locationManager.getAllProviders();
for (String provider: matchingProviders) {
Location location = locationManager.getLastKnownLocation(provider);
if (location != null) {
float accuracy = location.getAccuracy();
long time = location.getTime();
if ((time > minTime && accuracy < bestAccuracy)) {
bestResult = location;
bestAccuracy = accuracy;
bestTime = time;
}
else if (time < minTime &&
bestAccuracy == Float.MAX_VALUE && time > bestTime){
bestResult = location;
bestTime = time;
}
}
}
虽然其余的都很清楚,但这条线让我很难过:
else if (time < minTime &&
bestAccuracy == Float.MAX_VALUE && time > bestTime){
“时间”必须在可接受的延迟期内并且比之前的最佳时间更新。那讲得通。
但是 bestAccuracy 与 Max Float 值的比较是什么意思呢?精度何时会完全等于浮点数可以容纳的最大值?