// Takes a decimal number, and returns a binary number padded to length (len) // // Written By Sean Hyde-Moyer (Copywrite 1995-2003) // This program is released to the public under the terms of the // GNU GENERAL PUBLIC LICENSE // See http://www.gnu.org/copyleft/gpl.txt // For the full text of the license agreement main { x=11; y = binaryMac(x,8); info(y); } binaryMac: num,len //______Takes a decimal number, and returns a binary number padded to len { bin = ""; flag = 0; quotient = num; while(flag != 1){ tempStor = quotient/2; tempQuo = integer(tempStor); if(flag == 0){ tempBit = 1; if(frac(tempStor) == 0){ tempBit = 0; } quotient = tempQuo; } bin = string(tempBit,bin); if(tempQuo == 0) flag = 1; } looplen = size(bin); while(looplen < len){ bin = string(0,bin); ++looplen; } return(bin); }