bat 不支持浮点
你可以搜索论坛有BAT这方面的计算
暂写个也比较长 没完全测试
注意溢出- @echo off&setlocal enabledelayedexpansion
- set "k=00000000"
- set a=0.32
- set b=0.002
- for %%a in (a b) do (
- set "len_%%a="
- if "!%%a:*.=!" neq "!%%a!" (
- set .%%a=!%%a:*.=!
- for /l %%i in (9 -1 1) do if "!.%%a:~%%i!" == "" set "len_%%a=%%i"
- )
- for /f "tokens=* delims=0." %%i in ("!%%a:.=!") do set "%%a=%%i"
- )
- set /a len=len_a+len_b,n=a*b
- if !len! neq 0 for %%i in (!len!) do (
- set n=!k!!n!
- for /f "tokens=* delims=0" %%j in ("!n:~,-%%i!.!n:~-%%i!") do set "n=%%j"
- if "!n:~,1!" == "." set n=0!n!
- )
- echo !n!
- pause
复制代码 问题1- set aa=abcde
- set aa=%aa:~,2%F%aa:~2%
复制代码 问题2 什么意思? |