Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java remainder operation

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to use Java remainder operation". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

One, hit the scene.

Here are a few questions:

Note that m is the quotient and n is the remainder;

(1) positive % positive 3%2=m….n 2%3=m….n

(2)positive % negative or negative % positive-3%2=m….n 3%-2 = m….n -2%3=m….n 2%-3 =m….n

(3)Negative % Negative-3%-2=m….n -2%-3=m….n

II. Verification time

The following results have no quotient m and only a remainder n; are they all correct? If not, let's look at the summary

III. Summary

(1) 3%2=1…….1 2%3=0…….1

Divide a positive number by a positive number:

Quotient positive and Yu positive

(2) -3%2=-1…….- 1 3%-2=-1…….1 -2%3=0…….- 2 2%-3=0…….2

Either the divisor or dividend is negative:

First calculate according to positive number, quotient negative remainder same dividend

(Remainder and dividend have the same sign) You may have doubts about the result 0, you can think of it as negative 0, because dividend = divisor * quotient + remainder, so dividend is the result of hope quotient multiplied by divisor is close to it (for example, the last set of numbers dividend 2 is hope-3 multiplied by 0 is close to it, so it can be understood that 0 is negative 0, so it is generally applicable)

(3) -3%-2=1…….- 1 -2%-3=0…….- 2

Both numbers are negative:

Let's start with a positive number. The quotient is positive and the remainder is negative.

(For the second group, it can be understood that 0 is positive 0, and the explanation is the same as above)

"How to use Java remainder operation" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report