calling limitSigDigs() on a floater now raises an error. console console (Closes #862)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@4046 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -125,12 +125,17 @@ String.prototype.camelize = function() {
|
||||
* If null, 0, or negative value passed in, returns 0
|
||||
*/
|
||||
Number.prototype.limitSigDigs = function(sig) {
|
||||
var number = (sig > 0) ? this.toString() : 0;
|
||||
if (sig < number.length) {
|
||||
var exp = number.length - sig;
|
||||
number = Math.round( this / Math.pow(10, exp)) * Math.pow(10, exp);
|
||||
var numStr = (sig > 0) ? this.toString() : "0";
|
||||
if (numStr.contains(".")) {
|
||||
var msg = "limitSigDig can not be called on a floating point number";
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
}
|
||||
return parseInt(number);
|
||||
if ( (sig > 0) && (sig < numStr.length) ) {
|
||||
var exp = numStr.length - sig;
|
||||
numStr = Math.round( this / Math.pow(10, exp)) * Math.pow(10, exp);
|
||||
}
|
||||
return parseInt(numStr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user