' VB/ASP Version
Private Function CBin(Number As Integer) As String
Dim Temp As Variant
Temp = 1
Do Until Temp > Number
Temp = Temp * 2
Loop
Do Until Temp < 1
If Number >= Temp Then
CBin = CBin + "1"
Number = Number - Temp
Else
CBin = CBin + "0"
End If
Temp = Temp / 2
Loop
End Function
' Och en JavaScript-version:
function CBin(number) {
var temp;
var ret = new String();
temp = 1;
while( temp
}
while( temp>=1) {
if ( number>=temp) { ret+= "1"; number=number-temp;
} else {ret+= "0"; }
temp=temp/2;
}
return ret;
}