Tag Archives: toString

10,000 35 ways, .toString(radix);

Actionscript:
  1. for(var i:int = 2; i<37; i++){
  2.     trace((10000).toString(i));
  3. }
  4. /*
  5. outputs:
  6. 10011100010000
  7. 111201101
  8. 2130100
  9. 310000
  10. 114144
  11. 41104
  12. 23420
  13. 14641
  14. 10000
  15. 7571
  16. 5954
  17. 4723
  18. 3904
  19. 2e6a
  20. 2710
  21. 20a4
  22. 1cfa
  23. 18d6
  24. 1500
  25. 11e4
  26. kec
  27. iki
  28. h8g
  29. g00
  30. ekg
  31. dja
  32. cl4
  33. bpo
  34. b3a
  35. aci
  36. 9og
  37. 961
  38. 8m4
  39. 85p
  40. 7ps
  41. */

I had either totally forgotten about or never known about the Number, uint, int etc... .toString() radix argument. Brock mentioned it to me in conversation and I've been having fun with it ever since. It's especially nice for tracing out hex numbers:

Actionscript:
  1. var red:Number = 0xFF0000;
  2. trace("decimal:");
  3. trace(red);
  4. trace("hex:");
  5. trace(red.toString(16));

Posted in Number, strings | Also tagged , | Leave a comment