回复 15# JooKin
补码;
你别想复杂了,这是d2b的bat代码:- :: d2b.cmd
- @call dec2x.cmd 2 32 %1 %2
- @if %2.==. echo %$%
复制代码
- :: dec2x.cmd
- @ECHO %#debug% off
- :d2x <进制=2 8 16> <多少位> <数字> <返回>
- SETLOCAL ENABLEDELAYEDEXPANSION
- set /a "p=%1-1,x=(p-1)/3+^!(%1&16),d=%3,lp=%2"
- set m=0123456789ABCDEF&set h=
- for /L %%: in (1,1,%lp%)do set/a"t=d&p,d>>=x"&Set h=$m:~!t!,1$!h!
- for %%a in ("%h:$=!%")do endlocal&Set $%4=%%~a
复制代码 附带两个外部命令:- :: d2h.cmd
- @call dec2x 16 8 %1 %2
- @if %2.==. echo %$%
复制代码
- :: d2o.cmd
- @call dec2x 8 11 %1 %2
- @if %2.==. echo %$%
复制代码
|