puzzled needs resolving

July 29, 2011 at 13:02:49
Specs: Windows XP
three problems that someone might be able to resolve

@echo off & setlocal EnableDelayedExpansion
set LOOKUP=0123456789abcdef
set /a A=26
:loop
set /a B=!A! %% 16 & set /a A=!A! / 16
set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%
if !A! GTR 0 goto :loop
echo %HEXSTR%
pause

1)set /a B=!A! %% 16 & set /a A=!A! / 16

this line seems back to front

2)set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%

again back to front? & how is set /a A=!A! / 16 included in %HEXSTR%?*

3)Why does the loop need be?

@echo off & setlocal EnableDelayedExpansion
set LOOKUP=0123456789abcdef
set /a A=26
::loop
set /a B=!A! %% 16 & set /a A=!A! / 16
set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%
echo %HEXSTR%
pause

this catches the remainder

yeh slightly puzzling any help thanks


See More: puzzled needs resolving

Report •

#1
July 29, 2011 at 13:18:51
1) It's not.
2) It's not, and on subsequent passes of the loop.
3) To process the entire number.

I suggest removing the @echo off, and look at what it's doing.

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question