Again, reading one of the actionscript articles I ran into a script (in the Binary-Decimal Conversion Article) that I didnt understand completely.
// convert decimal number to binary string
function dec2bin(iNumber) {
var bin = "";
var oNumber = iNumber;
//this while method constructs a string from the number you enter as iNumber when you call the function
while (iNumber>0) {
if (iNumber%2) {
bin = "1"+bin;
} else {
bin = "0"+bin;
}
iNumber = Math.floor(iNumber/2);
}
// left pad with zeros
/*while (bin.length<15) {
bin = "0"+bin;
}*/
return bin;
}
Could anyone explain this piece of code for me.
Maybe by taking a decimal number as example and saying what Flash does with it, in the while loop, or smth
Thanks in advance
[size=2][font=Arial][size=2] [/size][/font][/size]