根据楼主要求:
1,移位数字范围为000到015
2,允许科学记数与普通数字(非16进制)混排
3,100行测试,运行时间小于0.08秒
4,所有科学记数转换的数字只精确到小数8位(未使用4舍5入)
5,对于小于0.00000001的数字,精确到0.00000001- @echo off
- for %%a in (*.txt) do (
- (for /f "usebackq delims=" %%b in ("%%a") do (
- setlocal enabledelayedexpansion
- set b=%%b
- if !b:~18^,1!==e set a==
- if !b:~19^,1!==e set a==
- if not defined a (echo.%%b) else (
- for /f "tokens=1,2* delims=e." %%c in ("%%b") do (
- set c=%%c&set d=%%d&set e=%%e&set f=!e:~2!
- if !f:~0^,1!==0 set f=!f:~1!
- if !c:~0^,1!==- set g=-&set c=!c:~1!
- if !c:~0^,1!==0 (echo.0) else (
- set h=!c!!d!
- if !e:~0^,1!==+ (
- set/a f+=1&for %%f in (!f!) do set h=!h:~0,%%f!.!h:~%%f!
- ) else (
- set/a f-=1&for /l %%f in (1,1,!f!) do set i=!i!0
- set h=0.!i!!h!
- )
- for /f "tokens=1* delims=." %%f in ("!h!") do set f=%%g&set h=%%f.!f:~0,8!
- if !h!==0.00000000 set h=0.00000001
- if not "!h:.=!"=="!h!" set "h=!h:0= !"&set "h=!h:.=#!"&for /f "delims=" %%f in ("!h!") do set h=%%~ff&set "h=!h:%cd%\=!"&set "h=!h:#=.!"&set "h=!h: =0!"
- if !h:~-1!==. set h=!h:~0,-1!
- echo.!g!!h!)))
- endlocal))>"%%a_"
- del /q "%%a"
- ren "%%a_" "%%a")
复制代码 结贴时,请修改主题并在前面加[已解决]
[ 本帖最后由 hanyeguxing 于 2010-5-2 20:36 编辑 ] |