免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1600 | 回复: 1
打印 上一主题 下一主题

expr精度不足? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-06-22 17:24 |只看该作者 |倒序浏览
  1. # expr 4737785 \* 1000
  2. 442817704
复制代码

我先试了除法,结果不对,我又反过来用*法,也不对嘛,后来发现expr
有上限啊。
以下为例
  1. expr 1234567890 \* 1000
  2. 1912276048
复制代码


查了man
      expr takes arguments as an expression, evaluates, then writes the
      result on the standard output.  Terms in the expression must be
      separated by blanks.  Characters special to the shell must be escaped.
      Note that 0, rather than the null string, is returned to indicate a
      zero value.  Strings containing blanks or other special characters
      should be quoted.  Integer-valued arguments can be preceded by a unary
      minus sign.  Internally, integers are treated as 32-bit, 2's
      complement numbers.

原来只能是32位整数,用bc好象上限高点,至少满足我的要求了。
只好现在开始想想用办法怎么把这个Bytes化为KBytes了。

论坛徽章:
0
2 [报告]
发表于 2004-06-24 14:38 |只看该作者

expr精度不足?

expr太弱了,全面改用bc
$ echo "scale=2; 1234567890*1000" | bc
1234567890000
还是bc好
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP