BC无视scale选项 [英] bc is ignoring scale option

查看:164
本文介绍了BC无视scale选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白,为什么BC工具有时会忽略该缩放选项。

下面是一个例子:

 >回声'规模= 2; 2.777  -  1.4744|公元前
1.3026

预期的结果是:

  1.30

其他信息:

 >庆典--version
GNU bash的版本2.05b.0(1) - 释放下(x86_64-SUSE Linux的)
版权所有(C)2002自由软件基金会
> BC --version
BC 1.06
版权所有1991- 1994年,1997年,1998年,2000自由软件基金会


解决方案

卡尔指出的那样,如果你检查手册页,你可以找到该行。它是关于前pression解释。减法不会阅读比例变量。如果你想获得预期的结果(1.30),你可以:

 肯特$回声'规模= 2; (2.777  -  1.4744)/ 1|公元前
1.30

/ 操作会读比例变量。

I can't figure out why bc tool sometimes ignores the scale option.

Here is an example:

> echo 'scale=2; 2.777 - 1.4744' | bc
1.3026

Expected result is:

1.30

Additional information:

> bash --version
GNU bash, version 2.05b.0(1)-release (x86_64-suse-linux)
Copyright (C) 2002 Free Software Foundation, Inc.
> bc --version
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.

解决方案

as Carl pointed out, if you check man page, you can find that line. it is about expression explanations. subtraction won't read scale variable. If you want to get the expected result (1.30), you could:

kent$  echo 'scale=2; (2.777 - 1.4744)/1' | bc 
1.30

/ operation will read scale variable.

这篇关于BC无视scale选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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