Changeset 7398
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/number.js
r7361 r7398 204 204 exponent: false}; 205 205 var parts = format.split('.'); 206 if(parts.length == 1){parts.fractional = false;} 206 var places = options.places; 207 if(parts.length == 1 || places === 0){flags.fractional = false;} 207 208 else{ 208 var places = options.places;209 209 if(typeof places == "undefined"){ places = parts[1].lastIndexOf('0')+1; } 210 if(places){parts.fractional = true;} // required fraction 210 if(places){flags.fractional = true;} // required fraction 211 if(!options.places && (places < parts[1].length)){ places += "," + parts[1].length; } 211 212 flags.places = places; 212 if(places < parts[1].length){ flags.places += "," + parts[1].length; }213 213 } 214 214 var groups = parts[0].split(','); … … 224 224 225 225 if(!options.strict){ 226 // TODO: handle .### with no leading integer?226 //TODO: handle .### with no leading integer as a strict option only? 227 227 //TODO: !strict: make currency symbol too 228 228 } … … 260 260 return NaN; //NaN 261 261 } 262 var numberExpression= results[1];263 if(typeof numberExpression== 'undefined'){262 var absoluteMatch = results[1]; 263 if(typeof absoluteMatch == 'undefined'){ 264 264 // matched the negative pattern 265 265 var negative = true; 266 numberExpression= results[2];267 } 268 numberExpression = numberExpression.replace(group, "", "g").replace(decimal, ".");269 value = Number( numberExpression);266 absoluteMatch = results[2]; 267 } 268 absoluteMatch = absoluteMatch.replace(group, "", "g").replace(decimal, "."); 269 value = Number(absoluteMatch); 270 270 271 271 if(!isNaN(value)){ -
trunk/src/regexp.js
r7365 r7398 332 332 333 333 // real number RE 334 return "(?:(?:"+ integerRE + decimalRE + ")|(?:" + decimalRE + "))" + exponentRE; // String 334 var realRE = integerRE + decimalRE; 335 // allow for decimals without integers, e.g. .25 336 if(decimalRE){realRE = "(?:(?:"+ realRE + ")|(?:" + decimalRE + "))";} 337 return realRE + exponentRE; // String 335 338 } 336 339