从CN-DOS的terse处得到一代码(如下)
经测试10进制转16进制没问题了
至于16进制转10进制我自己再琢磨一下
如果大家有好用的代码也可以贴上来帮忙下
- @echo off&setlocal enabledelayedexpansion
- set/p s=请输入十进制数:
- set/p x=请输入转换进制:
- set "str=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@"
- :lp
- set /a "n=8189,m=0,r=0"
- for /l %%a in (1,1,14) do (
- set /a "u=(n+m)/2"
- for %%i in (!u!) do if "!s:~%%i!" equ "" (set /a n=u) else set /a m=u
- )
- for /l %%i in (0,1,%u%) do (
- set/a "n=!s:~%%i,1!+(r*10),r=n%%x,n/=x"
- set v=!v!!n!
- )
- set b=!str:~%r%,1!!b!
- for /f "tokens=* delims=0" %%i in ("0!v!") do set "s=%%i"
- if defined s set v=&goto lp
- echo "!b!"
- pause
复制代码
|