What is the meaning of the percentage symbol in this code?

In this case, what does the percentage indicate?

int myInt = 27 % 10; myInt = 7; 

What does % mean in this code?

0
source share
4 answers

% means balance, when 27 is divided by 10, leaves a remainder of 7

 EDIT: 

My 2 cents about all discussions about the difference between module and remainder

Take% b

 1. When both +ve, Modulo & Remainder are one and the same 2. When a is -ve, they are not the same 

For instance:

a = -10, b = 3

Balance -10% 3 = -1

for Modulo, add the larger number of 3 to your 'a' and calculate the remainder.

-10 + 12 = 2

2% 3 = 2 - your answer

+5
source

% is the module operator, not the percentage. As a percentage, you just do ordinary math. 50% is multiplied by .5 ... etc.

For future reference, many places are documented with mathematical operations c, including here .

Note that % is called "Modulo" .

+3
source

% is the operator for finding the remainder of the division.

+1
source

The "%" in this code is called the module operator. This forces the processor to perform the division operation and returns the rest of the division.

For instance:

  • 8% 10 = 8
  • 5% 4 = 1
0
source

Source: https://habr.com/ru/post/1497290/


All Articles