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]);
}
}
@dsamarin
Copy link

/* pardon  */ (8.852546999924978e-8).toString(36).match(/[a-z]{5,}/g)[1] + " me";
/* shame   */ (8.47487600005451e-8).toString(36).match(/[a-z]{5,}/g)[0] + " on me";
/* orgasm  */ (101/49680).toString(33).match(/[a-z]{6,}/g)[20];
/* newton  */ (341/27650).toString(33).match(/[a-z]{6,}/g)[34] + " would be disappointed";
/* frowns  */ (1/4503599624754323).toString(36).match(/[a-z]{6,}/g)[0];
/* prepare */ "I didn't " + (Math.PI / 32954).toString(33).match(/[a-z]{6,}/g)[8] + " for this.";

~~ (761/708).toString(35).slice(1073,1079)

@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