devote,
function toBIN( num ) {
var out = "", bit = 1;
while( num > bit ) {
out = ( num & bit ? 1 : 0 ) + out;
bit <<= 1;
}
return out || "0";
}
*!*
alert( toBIN(4) );
*/!*
function toDEC( dec ) {
var out = 0, len = dec.length, bit = 1;
while( len-- ) {
out += dec[ len ] == "1" ? bit : 0;
bit <<= 1;
}
return out;
}
alert( toDEC( '0100' ) );
__________________
оляля, ололо
Последний раз редактировалось 9xakep, 24.07.2012 в 15:02.
|