如何在cmd中计算小数 [英] How Do Calculation of decimal numbers in cmd
本文介绍了如何在cmd中计算小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有批处理文件,当用户写数字时,会自动将数字加在一起而Cmd无法计算.
I have batch file and When user Writes number,Then automatically Adds numbers together And Cmd Can not calculate.
有什么主意吗?
推荐答案
这是批处理/vbscript混合.
批处理传递参数并解析结果并将其存储在变量Result
Here is batch/vbscript hybrid.
The batch passes the arguments and parses the result and stores it in the variable Result
::'@echo off &for /f "delims=" %%a in ('cscript //nologo //e:vbscript "%~f0" "%*"') do set "Result=%%a"
::'echo(Result=%Result%&exit /b
Wscript.echo Eval(Wscript.Arguments(0))
wscript.quit
::'
之后有一个不可见的字符(我希望它们会被转移)
There is one invisible char following the ::'
(I hope they get transferred)
一些示例,其中批处理文件存储为Math.cmd
(我的语言环境设置为小数逗号)
Some examples where the batch file is stored as Math.cmd
(my locale setting has a decimal comma)
>Math 3.76 + 2.54
Result=6,3
>Math 3.76 - 2.54
Result=1,22
>Math 3.76 * 2.54
Result=9,5504
>Math 3.76 / 2.54
Result=1,48031496062992
这篇关于如何在cmd中计算小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文