- @echo off
- setlocal enabledelayedexpansion
- set "hex=AB"
- for %%i in (
- "#0=0000"
- "#1=0001"
- "#2=0010"
- "#3=0011"
- "#4=0100"
- "#5=0101"
- "#6=0110"
- "#7=0111"
- "#8=1000"
- "#9=1001"
- "#A=1010"
- "#B=1011"
- "#C=1100"
- "#D=1101"
- "#E=1110"
- "#F=1111"
- ) do set %%i
-
- for %%i in (0 1) do (
- for %%j in (!hex:~%%i^,1!) do set "bin=!bin!!#%%j!"
- )
-
- echo %bin%
- echo bit2=%bin:~1,1%
- echo bit5=%bin:~4,1%
- pause
复制代码
|