仅能转换正整数到任意进制(64内 支持大数转换)- @echo off&setlocal enabledelayedexpansion
- set/p S=输入转换数:
- set/p H=请输入要转换的几进制?
- set "str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"
- :lp
- set Ln=&set R=&set "Sn=!s!"
- for %%i in (4096 2048 1024 512 256 128 64 32 16)do if "!Sn:~%%i!" NEQ "" set/aLn+=%%i&set Sn=!Sn:~%%i!
- set Sn=!Sn!FEDCBA9876543210&set/aLn+=0x!Sn:~16,1!
- for /l %%i in (0,1,%Ln%) do (
- set/a "N=!S:~%%i,1!+(R*10),R=N%%H,N/=H"
- set M=!M!!N!
- )
- set B=!str:~%r%,1!!B!
- for /f "tokens=* delims=0" %%i in ("0!M!") do set "S=%%i"
- if defined S set M=&goto lp
- echo "!B!"
- pause
复制代码
|