在批处理脚本小数 [英] decimals in batch script

查看:160
本文介绍了在批处理脚本小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

echo off
cls

mode con: cols=55 lines=15

:MAIN
color 07
cls

set /p num1="Specify first number: "
cls
set /p num2="Specify second number: "
cls

set /a num3=%num1%*%num2%

echo %num3%
pause

说NUM1 = 30和NUM2 = 0.10那就只能显示0而不是0.3让我怎么让它做小数和你会如何,如果需要显示出5位小数的地方?

Say num1 = 30 and num2= .10 then it would only display 0 and not .3 so how do I make it do decimals and how would you display out to 5 decimals places if needed?

推荐答案

批不支持浮点运算。你必须依靠外部脚本。

Batch does not support floating point arithmetic. You have to rely on external scripts.

http://www.computing.net/howtos/show/batch-script-floating-point-math/753.html

浮点师在DOS批处理

这篇关于在批处理脚本小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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