做了"功率为"在批处理文件功能存在吗? (指数) [英] Does a "Power to" function in batch files exist? (Exponent)

查看:145
本文介绍了做了"功率为"在批处理文件功能存在吗? (指数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有把一个变量电源等多项或其他变量的批处理文件的方法吗?请问这个函数存在吗?这方面的一个例子是,在Python中,你可以使用 ** 为给力。

Is there a way to put a variable "to the power" of a number or other variable a batch file? Does a function exist for this? An example of this would be in Python where you can use ** for "to the power of".

您可以做数学在批处理文件...... http://en.wikipedia.org/wiki / Batch_file

You can do maths in a batch file... http://en.wikipedia.org/wiki/Batch_file

推荐答案

电源的功能并不在批处理脚本可用,你可能已经从答案想通了。

The power to function is not available in batch scripting, as you may have already figured out from the answers.

一种选择是使用一个循环。你可以做循环的方式<一个href=\"http://stackoverflow.com/questions/5253356/how-to-do-the-power-to-function-in-batch-files-indexing/5255206#5255206\">@Kirk布罗德赫斯特做了最后一次,他不得不这样做批处理脚本,也可以用另一种方式,已成为可自那以后或可能有柯克被忽视:

One option is to use a loop. You can do the looping the way @Kirk Broadhurst did it last time he had to do the batch scripting, or you can use another way that has become available since then or otherwise may have gone unnoticed by Kirk:

:: calculate x^n
SET x=3
SET n=5
SET result=1
FOR /L %%i IN (1,1,%n%) DO SET /A result*=x
ECHO %result%

另一种选择是使用在<一个所描述的方法href=\"http://stackoverflow.com/questions/1503888/floating-point-division-in-a-dos-batch/1504046#1504046\">this的回答。

这篇关于做了&QUOT;功率为&QUOT;在批处理文件功能存在吗? (指数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆