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的修改

bc -l 对于 %取模计算出错的更多相关文章

  1. [Luogu P2261] [CQOI2007]余数求和 (取模计算)

    题面 传送门:https://www.luogu.org/problemnew/show/P2261 Solution 这题显然有一个O(n)的直接计算法,60分到手. 接下来我们就可以拿出草稿纸推一 ...

  2. mongoDB 高级查询之取模查询$mod

    http://hancang2000.i.sohu.com/blog/view/235140698.htm $mod取模运算   查询age取模10等于0的数据 db.student.find( { ...

  3. 组合数学中的常见定理&组合数的计算&取模

    组合数的性质: C(n,m)=C(n,n-m); C(n,m)=n!/(m!(n-m)!); 组合数的递推公式: C(n,m)=  C(n-1,m-1)+C(n-1,m); 组合数一般数值较大,题目会 ...

  4. 组合数取模Lucas定理及快速幂取模

    组合数取模就是求的值,根据,和的取值范围不同,采取的方法也不一样. 下面,我们来看常见的两种取值情况(m.n在64位整数型范围内) (1)  , 此时较简单,在O(n2)可承受的情况下组合数的计算可以 ...

  5. 【大数取模】HDOJ-1134、CODEUP-1086

    1086: 大数取模   题目描述 现给你两个正整数A和B,请你计算A mod B.为了使问题简单,保证B小于100000. 输入 输入包含多组测试数据.每行输入包含两个正整数A和B.A的长度不超过1 ...

  6. hdu 3944 DP? 组合数取模(Lucas定理+预处理+帕斯卡公式优化)

    DP? Problem Description Figure 1 shows the Yang Hui Triangle. We number the row from top to bottom 0 ...

  7. Re.多项式除法/取模

    前言 emmm又是暂无 前置 多项式求逆 多项式除法/取模目的 还是跟之前一样顾名思义] 给定一个多项式F(x),请求出多项式Q(x)和R(x),满足F(x)=Q(x)∗G(x)+R(x),R项数小于 ...

  8. 【BZOJ4944】【NOI2017】泳池 概率DP 常系数线性递推 特征多项式 多项式取模

    题目大意 有一个\(1001\times n\)的的网格,每个格子有\(q\)的概率是安全的,\(1-q\)的概率是危险的. 定义一个矩形是合法的当且仅当: 这个矩形中每个格子都是安全的 必须紧贴网格 ...

  9. UVA 11582 Colossal Fibonacci Numbers!(循环节打表+幂取模)

    题目链接:https://cn.vjudge.net/problem/UVA-11582 /* 问题 输入a,b,n(0<a,b<2^64(a and bwill not both be ...

随机推荐

  1. 洛谷 P1256 显示图像

    P1256 显示图像 题目描述 古老的显示屏是由N×M个像素(Pixel)点组成的.一个像素点的位置是根据所在行数和列数决定的.例如P(2,1)表示第2行第1列的像素点.那时候,屏幕只能显示黑与白两种 ...

  2. [ReasonML] Named & optional params

    // ::country is named param // ::country=?: which make it optional // because we make ::country=? op ...

  3. 【Material Design视觉设计语言】应用样式设计

    作者:郭孝星 微博:郭孝星的新浪微博 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells Github:https://github.co ...

  4. 简单的WINFORM窗口,体验WINFORM带来的快感

    当习惯成为一种自然,就不再喜欢那种条条框框的规则 using System; using System.Windows.Forms; namespace Window{ class Window{ s ...

  5. 使用wpaint绘图软件时:Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.

    使用wpaint绘图软件时:Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': Th ...

  6. 分组的listview——ExpandableListView

    开发使用到的数据统计时可以用分组的ExpandablelistView 效果:

  7. 洛谷P3201 [HNOI2009]梦幻布丁

    题目描述 N个布丁摆成一行,进行M次操作.每次将某个颜色的布丁全部变成另一种颜色的,然后再询问当前一共有多少段颜色.例如颜色分别为1,2,2,1的四个布丁一共有3段颜色. 输入输出格式 输入格式: 第 ...

  8. Java学习笔记四

    1.简介.进程和线程:简单的说就是进程负责为程序开辟内存空间,线程负责具体的执行单元(执行路径). 一个进程中可以有多个执行路径,称为多线程.CPU一次只能执行一个进程,但是一个进程内部可以有多个线程 ...

  9. BZOJ3529: [Sdoi2014]数表(莫比乌斯反演,离线)

    Description 有一张 n×m 的数表,其第 i 行第 j 列(1 <= i <= n, 1 <= j <= m)的数值为 能同时整除 i 和 j 的所有自然数之和.给 ...

  10. Docker 搭建java+tomcat

    1. 准备java和tomcat的软件包 jdk-7u79-linux-x64.tar.gz apache-tomcat-7.0.57.tar.gz 2. 编辑Dockerfile 文件 vim Do ...