当前位置:网站首页>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
边栏推荐
猜你喜欢
小黑leetcode之旅:94. 二叉树的中序遍历(补充Morris 中序遍历)
Don't use array.length-1 to get the last item of the array
《强化学习周刊》第57期:DL-DRL、FedDRL & Deep VULMAN
SQL语句及索引的优化
别叫我玩,我要考PMP:考PMP选择机构需要了解的那些事儿
FS4066耐高压1到4节内置MOS的锂电池充电管理芯片
hdu 1503 Advanced Fruits(最长公共子序列的应用)
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
Word第一页空白页怎么删除?删除Word第一页空白页方法教程
[Generic Programming] Full Detailed Explanation of Templates
随机推荐
leetcode: the Kth largest element in the array
Don't tell me to play, I'm taking the PMP exam: what you need to know about choosing an institution for the PMP exam
SecureCRT强制卸载
基于Docker构建MySQL主从复制数据库
hdu 1503 Advanced Fruits(最长公共子序列的应用)
How to fix Windows 11 not finding files
Simple questions peek into mathematics
【Efficient Tools】Remote Control Software ToDesk (Favorites)
【云原生】4.2 DevOps 精讲篇
4D Summary: 38 Knowledge Points of Distributed Systems
STC8H development (15): GPIO drive Ci24R1 wireless module
QGIS编译SIP的问题
Pagoda measurement - building LightPicture open source map bed system
ACM MM 2022 | Cloud2Sketch: 长空云作画,AI笔生花
fixed investment fund
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
微软word怎么转换成pdf文件?微软word转换为pdf格式的方法
Word第一页不要页眉怎么设置?设置Word首页不要页眉方法教程
LoRa Basics无线通信技术和应用案例详解
windos安装Mysql8.0,及解决重新登录异常问题 ERROR 1045 (28000)