弹性模量
Just a thought on the exam prep question 1.
只是对考试准备问题1的思考。
The question in its essence is "How much is 3 - 5 % 3"; The answer is 1 because 5 % 3 is 2 and 3 - 2 is 1.
本质上的问题是“ 3-5%3多少钱”; 答案是1,因为5%3是2,而3-2是1。
That's exactly what the book says but in the explanation of the correct answer there's a mistake saying that 5%2 is 2 when it should be 1.
这正是书中所说的,但是在对正确答案的解释中,有一个错误说5%2是2,而应该是1。
So just a quickie - how the modulus thing works? Well, it's starts with a division and then gives the reminder of the division that would give a whole number. In other words:
因此,只是一个快捷方式-模数是如何工作的? 好吧,它从一个除法开始,然后提醒该除法将给出一个整数。 换一种说法:
- 5 % 3 is like 5 - 3 because 3 / 3 will give the whole number 1. 5%3就像5-3,因为3/3将得到整数1。
- 5 % 2 is 5 - 4 because 4 /2 will give the whole number 2 5%2是5-4,因为4/2将得出整数2
- 5 % 4 is 1 because 4/4 is a whole number and 5-4 is 1 5%4是1,因为4/4是整数,而5-4是1
- 5 % 5 and 5 % 1 both give a nice round 0, because 5/5 gives the whole number 1 and there is no reminder. The same way 5 / 1 gives the whole number 5 and there is no reminder. 5%5和5%1都给出一个不错的回合0,因为5/5给出了整数1,并且没有提醒。 同样的方法5/1给出整数5,并且没有提醒。
The important thing the guide mentions is that the modulus operation in php can give negative results unlike the modulus in the math. The result will be negative only if the first number is negative. I.e. 5 % (-2) = 1
while -5 % 2 = -1
该指南提到的重要一点是,与数学中的模数不同,php中的模数运算可以给出负结果。 仅当第一个数字为负数时,结果才为负数。 即5 % (-2) = 1
而-5 % 2 = -1
Tell your friends about this post on Facebook and Twitter
在Facebook和Twitter上告诉您的朋友有关此帖子的信息
弹性模量