当前位置:网站首页>In programming languages, the difference between remainder and modulo
In programming languages, the difference between remainder and modulo
2022-08-09 23:13:00 【Full stack programmer webmaster】
Hello everyone, meet again, I'm your friend Quanstack Jun.
Take the remainder and follow the principle of keeping the quotient as close to 0 as possible
Take the modulo and follow the principle of making the quotient as close to negative infinity as possible
In matlab, the remainder and modulo are defined as follows:
When y≠0:
Remainder: rem(x,y)=x-y.*fix(x./y)
Modulus: mod(x,y)=x-y.*floor(x./y)
Among them, the fix() function is to round to 0, and the floor() function is to round to negative infinity
Operation example:
7/(-3)=-2.3, in this operation, x is 7, y is -3, call the two functions fix() and floor() respectively, the result is:
fix(-2.3)=-2
floor(-2.3)=-3
So, rem(7,-3)=1, mod(7,-3)=-2
Publisher: Full-stack programmer, please indicate the source: https://javaforall.cn/105810.htmlOriginal link: https://javaforall.cn
边栏推荐
- TF生成均匀分布的tensor
- ACM MM 2022 | Cloud2Sketch: Painting with clouds in the sky, AI brush strokes
- C语言中的文件是什么?
- SecureCRT背景配色
- [corctf 2022] section
- LeetCode26:删除有序数组中的重复项
- Jmeter 使用正则表达式提取器将返回值全部保存到一个文件中
- AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
- gmail+mtalk配合打免费网络电话。
- poj 3070 Fibonacci(简单矩阵连乘)
猜你喜欢
STC8H Development (15): GPIO Drives Ci24R1 Wireless Module
XXE-XML外部实体注入-知识点
Install Mysql8.0 on windos, and solve the problem of re-login exception ERROR 1045 (28000)
论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
Unity2D_线框材质
Optimization of SQL Statements and Indexes
普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?
ACM MM 2022 | Cloud2Sketch: 长空云作画,AI笔生花
QGIS编译SIP的问题
AI+医疗:使用神经网络进行医学影像识别分析
随机推荐
场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon
Word怎么制作一张标准的答题卡?
6个规则去净化你的代码
leetcode: the Kth largest element in the array
Word第一页空白页怎么删除?删除Word第一页空白页方法教程
[Generic Programming] Full Detailed Explanation of Templates
Pagoda measurement - building LightPicture open source map bed system
mysql多表左链接查询
Problems with compiling SIP with QGIS
UE4_定序器控制蓝图对象
微软Excel表格点击单元格行和列都显示颜色怎么弄?聚光灯效果设置
C语言中的文件是什么?
Word文档怎么输入无穷大符号∞
【stack】【queue】【priority_queue】【deque】Detailed explanation
SQL语句及索引的优化
角度和弧度的相互换算
Interpretation of the paper (DropEdge) "DropEdge: Towards Deep Graph Convolutional Networks on Node Classification"
Usage of placeholder function in Tensorflow
Word怎么设置图片衬于文字下方?两种方法教你设置Word图片衬于文字下方
技术分享 | 接口自动化测试之JSON Schema模式该如何使用?