Skip to content

Instantly share code, notes, and snippets.

@zootella
Created April 30, 2013 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zootella/5486195 to your computer and use it in GitHub Desktop.
Save zootella/5486195 to your computer and use it in GitHub Desktop.
function _number(s, base) {
if (typeof s !== "string") throw "type";
var n = parseInt(s, base);
if (isNaN(n)) throw "data";
if (!match(_numerals(n, base), s)) throw "data"; // Guard against parseInt's dangerously accommodating parsing style by ensuring that the number we made becomes the same text we made it from
return n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment