I see the following code, very incisive! Please ask the teacher for guidance!
@echo off&setlocal enabledelayedexpansion
:: Code 5
:: Code by CN-DOS terse
set "hx=0123456789ABCDEF"
set/p str=:
for /l %%i in (1 1 8) do (
if !str! GTR 0 (
set/a "n=str&15,str>>=4"
call set h=%%hx:~!n!,1%%!h!
)
)
if not defined h set "h=0"
echo.%str% 的十六进制为:0x!h!
pause
1,
%%i ranges from 1 to 8, why? But no place to see %%i?
2,
set/a "n=str&15,str>>=4"
It means taking the remainder, but I can't understand it at all.....
If written according to my way, it becomes like this:
set /a y= str%%16
set /a ya=str/16%%16
set /a yb=str/256%%16
set /a yc=str/4096%%16
set /a yd=str/65536%%16
set /a ye=str/1048576%%16
set /a yf=str/16777216%%16
set /a yg=str/268435456%%16
set m=0123456789ABCDEF
set cdm=!m:~%yg%,1!!m:~%yf%,1!!m:~%ye%,1!!m:~%yd%,1!!m:~%yc%,1!!m:~%yb%,1!!m:~%ya%,1!!m:~%y%,1!
[ Last edited by ZJHJ on 2010-8-18 at 00:36 ]
@echo off&setlocal enabledelayedexpansion
:: Code 5
:: Code by CN-DOS terse
set "hx=0123456789ABCDEF"
set/p str=:
for /l %%i in (1 1 8) do (
if !str! GTR 0 (
set/a "n=str&15,str>>=4"
call set h=%%hx:~!n!,1%%!h!
)
)
if not defined h set "h=0"
echo.%str% 的十六进制为:0x!h!
pause
1,
%%i ranges from 1 to 8, why? But no place to see %%i?
2,
set/a "n=str&15,str>>=4"
It means taking the remainder, but I can't understand it at all.....
If written according to my way, it becomes like this:
set /a y= str%%16
set /a ya=str/16%%16
set /a yb=str/256%%16
set /a yc=str/4096%%16
set /a yd=str/65536%%16
set /a ye=str/1048576%%16
set /a yf=str/16777216%%16
set /a yg=str/268435456%%16
set m=0123456789ABCDEF
set cdm=!m:~%yg%,1!!m:~%yf%,1!!m:~%ye%,1!!m:~%yd%,1!!m:~%yc%,1!!m:~%yb%,1!!m:~%ya%,1!!m:~%y%,1!
[ Last edited by ZJHJ on 2010-8-18 at 00:36 ]

