简体   繁体   English

全新的软件工程

[英]Brand new to software engineering

I'm extremely new to software engineering and I don't fully understand how modulus.我对软件工程非常陌生,我不完全了解模数。 I understand it with simple numbers but one example I don't understand is how (0-1) % 60 equals 59. Hoping someone doesn't mind answering this very much beginner's question.我用简单的数字理解它,但我不明白的一个例子是 (0-1) % 60 如何等于 59。希望有人不介意回答这个非常初学者的问题。

Think about modulo as dividing the first number by the second number and then taking the remainder.将模数视为将第一个数字除以第二个数字,然后取余数。
For instance 10 % 2 is 0 because 10 is 10 / 2 = 5 R 0.例如,10 % 2 是 0,因为 10 是 10 / 2 = 5 R 0。
Also 5 % 4 = 1 because 5 / 4 = 1 R 1.还有 5 % 4 = 1,因为 5 / 4 = 1 R 1。

Then to go to your example:然后转到您的示例:
-1 % 60 = -1 R 59 -1 % 60 = -1 R 59
This is because a remainder always has to be positive and -1 * 60 + 59 = -1这是因为余数必须始终为正且 -1 * 60 + 59 = -1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM