当前位置:网站首页>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清爽雨天之旅,刚吃完宇飞牛肉面、麻辣烫和啤酒:112. 路径总和
- MySQL:错误1153(08S01):得到的数据包大于“ max_allowed_packet”字节
- 【stack】【queue】【priority_queue】【deque】Detailed explanation
- 简单问题窥见数学
- NIO Cup 2022 Nioke Summer Multi-School Training Camp 7 CFGJ
- 浅谈Numpy中的shape、reshape函数的区别
- Simulation of Water Temperature Control System Based on Fuzzy PID Controller
- 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
- Use zeros(), ones(), fill() methods to generate data in TF
- STC8H开发(十五): GPIO驱动Ci24R1无线模块
猜你喜欢

CVPR22 Oral | shunt through multi-scale token polymerization from attention, code is open source

Lyapp exponents and bifurcation diagrams for fractional chaotic systems

几种绘制时间线图的方法

Word怎么设置图片衬于文字下方?两种方法教你设置Word图片衬于文字下方

XXE-XML外部实体注入-知识点

微软Excel表格点击单元格行和列都显示颜色怎么弄?聚光灯效果设置

宝塔实测-搭建LightPicture开源图床系统

cad图纸怎么复制到word文档里面?Word里插CAD图怎么弄?

UE4_定序器控制蓝图对象

论文解读(DropEdge)《DropEdge: Towards Deep Graph Convolutional Networks on Node Classification》
随机推荐
场效应管Mosfet之雷卯Leiditech对应英飞凌Infineon
Use zeros(), ones(), fill() methods to generate data in TF
RHEL7系统修复rm -rf /boot /etc/fstab
hdu 3341 Lost's revenge(dp+Ac自动机)
Hessian Matrix 海森矩阵
Technology Sharing | How to Handle Header Cookies in Interface Automation Testing
普源精电上半年扭亏为盈,高端产品持续发力!你看好仪器界“华为”吗?
10个 Istio 流量管理 最常用的例子,你知道几个?
Word第一页空白页怎么删除?删除Word第一页空白页方法教程
Don't use array.length-1 to get the last item of the array
Leetcode 93 复原IP地址
mysql多表左链接查询
PMP每日一练 | 考试不迷路-8.8(包含敏捷+多选)
NIO Cup 2022 Nioke Summer Multi-School Training Camp 7 CFGJ
MySQL跨表、多表更新SQL语句总结
浅谈Numpy中的shape、reshape函数的区别
AI Knows Everything: Building and Deploying a Sign Language Recognition System from Zero
蔚来杯2022牛客暑期多校训练营7 CFGJ
Definition and Basic Operations of Sequence Tables
C语言预处理命令是什么?