M
M
m_frost2019-03-26 22:37:13
JavaScript
m_frost, 2019-03-26 22:37:13

Remainder after dividing by 1?

And so in js there is an operator % remainder of division, it is convenient for them to check the evenness of a number ( n%2 == 0 ) and ATTENTION is it an integer of the type if the number is an integer then num%1 will be zero if the fraction is 0+fraction but I can’t understand because if you divide the number by 1, then there will be a number and not 0, that is, the remainder will always be the number that we divided by 1.
Maybe I don’t know math well, or is it fun js explain please.
Sorry for the letter too lazy to put the Russian layout.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Olohtonov, 2019-03-26
@m_frost

% is the operation of taking the remainder of the division, not the quotient. The remainder of dividing any integer by 1 is 0, since any integer can be represented as a sum of units, and 1 is divisible by 1 without a remainder.
Example:
3% 1 = 3 (mod 1) = 1 + 1 + 1 (mod 1) = 0 + 0 + 0 = 0

R
Ronald McDonald, 2019-03-26
@Zoominger

if the number is an integer then num%1 will be zero

An integer divided by 1 always gives itself:
x : 1 = x

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question