# hex batch

July 27, 2011 at 06:52:28
Specs: Windows XP
 Bit of a long shot but if you don't ask....so could anyone kindly explain the process below its more the method of division and using set lookup this would help me, thanks.@echo off & setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSIONset LOOKUP=0123456789abcdef &set HEXSTR=&set PREFIX=if "%1"=="" echo 0&goto :EOFset /a A=%*if !A! LSS 0 set /a A=0xfffffff + !A! + 1 & set PREFIX=f:loopset /a B=!A! %% 16 & set /a A=!A! / 16set HEXSTR=!LOOKUP:~%B%,1!%HEXSTR%if %A% GTR 0 goto :loopecho %PREFIX%%HEXSTR%

See More: hex batch

#1
July 28, 2011 at 02:53:40
 set /a B=!A! %% 16 Carries out a modulo operation (indicated by %%) on the value stored in environment variable A and stores the result returned in environment variable B. e.g. 31 %% 16 returns 15 (in this example the result will always be less than 16). set /a A=!A! / 16 Divides the value stored in environment variable A and stores the resulting integers (whole numbers) in an amended environment variable A e.g. 22/16 = 1.375 A will be set to 1Hope this helps. Please come back & tell us if your problem is resolved.

Report •

#2
July 29, 2011 at 07:28:34
 Easy way to convert decimal to hexSet LOOKUP=0123456789abcdefEasy as pie here's how, A the number (Integer) being converted to hex needs to be divided. But it's important to remember the method of division. So lets use 26 how many times can 16 go into 26 answer is 1 times now whats remaining? 10.So lets look both those numbers up in the LOOKUP table. We start with 1 = 1 thats the first number then 10 counting on from 0 we arrive @ A so 26 = 1A.Thanks to Wahine

Report •

#3
July 30, 2011 at 15:57:53
 REVISE on above if doing above 255 take note of remainder and for the divisor you have to convert to to hex example 555 / 16 = 34* r 11. 11=B now 34 /16 =2 r2 =22+B==22B==555

Report •

Related Solutions