diff --git a/lib/OpenLayers/BaseTypes.js b/lib/OpenLayers/BaseTypes.js index b5735b8f0d..120b7c03d4 100644 --- a/lib/OpenLayers/BaseTypes.js +++ b/lib/OpenLayers/BaseTypes.js @@ -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); }