java - What does comparing accuracy to Float.MAX_VALUE mean? -


while reading android developers blog post on location, came across bit of code (cut & paste blog):

list<string> matchingproviders = locationmanager.getallproviders(); (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;     }   } } 

while rest pretty clear, line has me stumped:

    else if (time < mintime &&           bestaccuracy == float.max_value && time > besttime){ 

'time' has within acceptable latency period & more recent previous besttime. makes sense.

but comparison of bestaccuracy max float value mean? when accuracy equal maximum value float can hold?

that particular bit makes more sense if follow link whole source file. here's bigger snippet:

location bestresult = null; float bestaccuracy = float.max_value; long besttime = long.min_value;  // iterate through providers on system, keeping // note of accurate result within acceptable time limit. // if no result found within maxtime, return newest location. list<string> matchingproviders = locationmanager.getallproviders(); (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;     }   } } 

very simply, float.max_value default value bestaccuracy , he's checking hasn't reduced in previous if clause.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -