Skip to content

Instantly share code, notes, and snippets.

@codrineugeniu
Forked from mathiasbynens/lolwat.js
Created August 10, 2012 19:23
Show Gist options
  • Save codrineugeniu/3317072 to your computer and use it in GitHub Desktop.
Save codrineugeniu/3317072 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]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment