Skip to content

Instantly share code, notes, and snippets.

@mathiasbynens
Created August 18, 2011 10:48
Show Gist options
  • Save mathiasbynens/1153826 to your computer and use it in GitHub Desktop.
Save mathiasbynens/1153826 to your computer and use it in GitHub Desktop.
Fun with v8’s Number#toString bug
var number = 0,
increment = 0.00000000000001, // smallest value that makes a difference
result,
matches,
match;
for (; number < 100; number += increment) {
result = number.toString(33);
matches = result.match(/[a-z]+/g) || [];
match = matches.indexOf('wtf');
if (match > -1) {
console.log('(' + number + ').toString(33).match(/[a-z]+/g)[' + match + ']; // ' + matches[match]);
}
}
@tomasdev
Copy link

/* I */ (1.2967999999998688e-10).toString(33).match(/[a-z]+/g)[185] /* this */

@aredridel
Copy link

897217487244305.0.toString(33) + " is super fun"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment