Skip to content

Instantly share code, notes, and snippets.

View brundage's full-sized avatar
🚲
Unscrambling eggs

Dean Brundage brundage

🚲
Unscrambling eggs
View GitHub Profile
@brundage
brundage / decimal_arithmetic.js
Created May 18, 2012 13:28
Problematic Decimal Arithmetic in Javascript
// decimal_arithmetic.js
// From http://www.brewsession.com/problematic-decimal-arithmetic-in-javascript/
String.prototype.digitsAfterDecimal = function()
{ var parts = this.split(".", 2); // FIXME: Not international!
if( ! parts[1] )
{ parts[1] = ""; }
return parts[1].length;
};