K
K
krembrule20162019-11-17 11:00:06
Java
krembrule2016, 2019-11-17 11:00:06

How is the conversion to seconds done?

Hey!
*Carefully! Stupid question!*
Due to the lack of knowledge of the Java language, I can not understand the essence of this line of code: The variable second is a regular int, which is incremented every second. When it becomes more/multiple or equal to 60, then everything is clear, the countdown starts from the beginning 0..1..2..3.. etc. But, when second counted, for example, 1, then the remainder of the integer division is SUMBUREN (0.016666 ...), but what is needed still gets into the sex variable. How does this happen? Where is the magic?
int secs = second % 60;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Developer, 2019-11-17
@krembrule2016

This is not an integer division, but a remainder.
1% 60 = 1
62% 60 = 2
185% 60 = 5

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question