Browse the notebook

Tag: hex

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

for(var i:int = 2; i<37; i++){
	trace((10000).toString(i));
}
/*
outputs:
10011100010000
111201101
2130100
310000
114144
41104
23420
14641
10000
7571
5954
4723
3904
2e6a
2710
20a4
1cfa
18d6
1500
11e4
kec
iki
h8g
g00
ekg
dja
cl4
bpo
b3a
aci
9og
961
8m4
85p
7ps
*/

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:

var red:Number = 0xFF0000;
trace("decimal:");
trace(red);
trace("hex:");
trace(red.toString(16));
Read snippet: 10,000 35 ways, .toString(radix);