Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Convert Decimal Integer Int Binary Mod 2 Base 2 10
AddExtender("wilx44i.dll") dec = AskLine("Base conversion", "Enter a decimal value", 11) bin = xBaseConvert(dec, 10, 2) Pause("Notice", dec : " converted to binary is: " : bin) Exit
#DefineFunction Dec2Binary(number) binarray = ArrDimension(10) ArrInitialize (binarray, "") count = 0 While(number!=0) ; keep looping until we cannot do any more calculations binarray[count] = number mod 2 number=number/2 count=count+1 EndWhile binary = "" size = ArrInfo(binarray, 1)-1 For x = size To 0 By -1 binary = binary : binarray[x] Next Return binary #EndFunction number = AskLine( "Dec2Binary", "Please enter a positive integer: ", 11 ) If number < 0 Pause("Notice","That is not a positive integer") Exit ElseIf !IsNumber( number ) Pause("Notice","That is not a valid integer") Exit Else result = Dec2Binary(number) Pause("Notice", number : " converted to binary is: " : result) EndIf Exit
Article ID: W18345
Filename: Convert Decimal to Binary.txt
File Created: 2011:04:15:11:02:06
Last Updated: 2011:04:15:11:02:06