bc -l 对于 %取模计算出错
https://yq.aliyun.com/articles/279384
expr % expr
The result of the expression is the "remainder" and it is com‐
puted in the following way. To compute a%b, first a/b is com‐
puted to scale digits. That result is used to compute a-(a/b)*b
to the scale of the maximum of scale+scale(b) and scale(a). If
scale is set to zero and both expressions are integers this
expression is the integer remainder function.
# bc -l
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1/3
.33333333333333333333
--//可以看出使用math 库,缺省scale=20.
--//而如果不使用-l参数scale=0.
--//这样如果在scale=20的情况,取模使用是这样.
12312324/1232
9993.76948051948051948051
12312324-9993.76948051948051948051*1232
.00000000000000001168
scale=2
12312324%1232
11.68
12312324/1232
9993.76
--//bc竟然没做四舍五入.
12312324-9993.76*1232
11.68
===========================
C:\Windows\system32>bc
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1/3
0
C:\Windows\system32>bc -l
bc 1.05
Copyright 1991, 1992, 1993, 1994, 1997, 1998 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
1/3
.33333333333333333333
(interrupt) use quit to exit.
C:\Windows\system32>
vim的修改
最新文章
- WCF学习之旅—实现REST服务(二十二)
- .ashx中使用Session
- Canvas绘制图形
- MIME参考列表
- gcc 版本降级
- java中String的常用方法
- openstack context
- MON166 FAQ
- 09 - 删除vtkDataObject中的ShouldIReleaseData() and ReleaseDataFlag 方法 VTK 6.0 迁移
- C# 泛型 Func<;object, string, bool>; filter
- HttpClient 4.3连接池参数配置及源码解读
- 201521123029《java程序设计》第2周学习总结
- 团队项目第二阶段个人进展——Day4
- 使用autohotkey修改方向键、回车和启动程序
- vue组件通信那些事儿
- kubernetes环境搭建
- [动态dp]线段树维护转移矩阵
- SpringBoot与docker
- webpack 4 知识点
- Influxdb安装部署
热门文章
- 微信小程序从零开始开发步骤(七)引入外部js 文件
- [RxJS] Marbles Testings
- 6.Windows 二进制文件 (.exe)安装--终端安装
- ASP.NET MVC 4 (十一) Bundles和显示模式--asp.net mvc中 @Scripts.Render(";~/bundles/jquery";)是什么意思? 在布局文件中使用Scripts.Render()输出脚本包,Styles.Render()输出风格包:
- windows防火墙开放zabbix端口(批处理)
- Android Service com.android.exchange.ExchangeService has leaked ServiceConnection
- [python]bug和debug
- .net core 修改网站启动端口
- JSP学习 —— 开篇:JSP,servlet容器,Tomcat,servlet容器之间的关系
- 关于javascript中私有作用域的预解释