@foxidrive
thanks! you are very exhaustive.
I have tested and the fastest is 3rd approach as said aGerman
@aGerman
thanks, the for %%P in (8 4 2 1) do .. is more faster.
I have broken down and this is the result:
Code: Select all
@echo off
set "num=987654321"
setlocal EnableDelayedExpansion
set /a "n=1!num!, len=0"
if "!n:~8,1!" NEQ "" set /a "len=8, n/=100000000"
if "!n:~4,1!" NEQ "" set /a "len+=4, n/=10000"
if "!n:~2,1!" NEQ "" set /a "len+=2, n/=100"
if "!n!" geq "0" set /a "len+=1"
endlocal &set "len=%len%"
echo %len%
but i thinks that is possible to optimize yet.
EDIT: this approch do not WORK!
einstein1969