@echo off & setlocal enableextensions
set decimal_=78
call :DecimalToBinary %decimal_% binary_
echo Decimal %decimal_% = Binary %binary_%
::
call :DecimalToOctal %decimal_% oct_
echo Decimal %decimal_% = Octal %oct_%
::
call :DecimalToHex %decimal_% hex_
echo Decimal %decimal_% = Hexadecimal %hex_%
endlocal & goto :EOF
::
::===============================================================
:DecimalToBinary DecimalIn BinaryOut
::
setlocal enableextensions
set /a dec_=%1
if %dec_% LSS 0 (endlocal & set %2=Error: negative & goto :EOF)
set bin_=
:_binloop
set /a dec1_=%dec_%
set /a dec_=%dec_% / 2
set /a bindigit_=%dec1_% - 2*%dec_%
set bin_=%bindigit_%%bin_%
if %dec_% GTR 0 goto :_binloop
endlocal & set %2=%bin_% & goto :EOF
::
::===============================================================
:DecimalToOctal DecimalIn OctalOut
::
setlocal enableextensions
set /a dec_=%1
if %dec_% LSS 0 (endlocal & set %2=Error: negative & goto :EOF)
set oct_=
:_octloop
set /a dec1_=%dec_%
set /a dec_=%dec_% / 8
set /a octdigit_=%dec1_% - 8*%dec_%
set oct_=%octdigit_%%oct_%
if %dec_% GTR 0 goto :_octloop
endlocal & set %2=%oct_% & goto :EOF
::
::===============================================================
:DecimalToHex DecimalIn HexOut
::
setlocal enableextensions
set /a dec_=%1
if %dec_% LSS 0 (endlocal & set %2=Error: negative & goto :EOF)
set hex_=
:_hexloop
set /a dec1_=%dec_%
set /a dec_=%dec_% / 16
set /a hexdigit_=%dec1_% - 16*%dec_%
set /a hexidx_=%hexdigit_%+1
for /f "tokens=%hexidx_%" %%h in (
'echo 0 1 2 3 4 5 6 7 8 9 A B C D E F') do set hexdigit_=%%h
set hex_=%hexdigit_%%hex_%
if %dec_% GTR 0 goto :_hexloop
endlocal & set %2=%hex_% & goto :EOF
The output will be
D:\TEST>cmdfaq
Decimal 78 = Binary 1001110
Decimal 78 = Octal 116
Decimal 78 = Hexadecimal 4E