In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to achieve negative modulus in Utility", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "how to achieve negative modulus in Utility" this article.
Recently, when I was learning table division with my child, I came up with a question: how to deal with negative modulus in C language?
In-table division: 12 / 4 / 3
Integer division: 13. 4 = 3. one
Integer division: is 13 pound 4 equal to 3?
Negative number module:-13% 4 equals how much? What about 13% Murray 4? -13% Murray 4?
Let's take a look at division. It is obvious that the division cannot be done, and the result is required to be an integer. Generally, there are several methods:
Round up (Ceiling), that is, snap to + ∞, which is the smallest integer that is slightly larger than the result of a floating point number. So: 13According to the fact that there is no doubt about the fact that there is no need for us to do so, we will not be able to do so.
Floor, that is, snap to-∞, that is, the largest integer that is slightly smaller than the result of a floating-point number. So: 13According to the fact that there is no doubt about the fact that there is no need for us to do so, we will not be able to do so.
Rounding (Round), that is, the difference between the integer result and the floating point result is not more than 0.5; when the difference is 0.5, take the integer with a larger absolute value. So: 13According to the fact that there is no doubt about the fact that there is no need for us to do so, we will not be able to do so.
Round to zero (Truncate), that is, snap to 0, that is, to strip out the decimal part. So: 13According to the fact that there is no doubt about the fact that there is no doubt about it, the following is true: 13According to the fact that there is no doubt about the fact that there is no need for us to do so, we will be able to do so.
The integral division in C language is rounded to zero (Truncate).
Let's take a look at the mold. No matter which kind of divisible operation, it will conform to the formula: divisor / divisor = quotient. Remainder, so: remainder = divisor-divisor * quotient.
Then the module in C language is:
13. 4 = 3. 1PUBE 13 / 4mm MUE 3... -1 Ting 13 / 4 Qing Mui 3... 1 Ting Mui 13 /-4 Qing 3... -1
15. 4 = 3. 3 Ting Mui 15 / 4 Qing Mui 3... -3 / 3 / 3 / 4 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 3 / 4 3 Ting Mui 15 /-4 Qing 3... -3
The rule is that the remainder and the divisor have the same symbol.
It seems that among these four operations, division is much more complicated than the other three.
These are all the contents of this article entitled "how to achieve negative Modulus in Utility". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.