in , , , ,

These isEven posts are lacking in whats most important: documentation

These isEven posts are lacking in whats most important: documentation | programming-memes, program-memes, forms-memes, function-memes, rest-memes, express-memes, cli-memes, IT-memes, ide-memes, documentation-memes, div-memes, language-memes, cs-memes, programming language-memes | ProgrammerHumor.io
programming-memes, program-memes, forms-memes, function-memes, rest-memes, express-memes, cli-memes, IT-memes, ide-memes, documentation-memes, div-memes, language-memes, cs-memes, programming language-memes | ProgrammerHumor.io

[text] def isevennum Addition subtraction multiplication and division. These are the four mathematical operations I was taught during my childhood education and their operators are very familiar. I was not taught the modulus operator which I recently discovered can be quite useful and interesting in its own right. The modulus operator written in most programming languages as or mod performs what is known as the modulo operation. You next response understandably might be That doesnt clarify anything so lets take TR The modulus operator or more precisely the modulo operation is a way to determine the remainder of a division operation. Instead of returning the result of the division the modulo operation returns the ST Some examples may help illustrate this as its not necessarily intuitive the first time you encounter it 510 15 divided by 1 equals 5 with a remainder of 0 521 15 divided by 2 equals 2 with a remainder of 1 It may be helpful to think back to your early math lessons before you learned fractions and decimals. Mathematics with whole numbers behaves differently when dividing numbers that arent even multiples theres aluays some amount left over. That remainder is what the modulo operation returns. If this seems strange boring or not particularly useful bear with me a bit longer or just skip ahead to the use cases. The Modulo Operation Expressed As a Formula As one final means of explication for those more mathematically inclined L T e s ERNCRR N By substituting values we can see how the modulo operation works in practice 1007 2 R 100 7 floor1007 2 If you dont Find the formula helpful dont worry I didnt either at first. Some people find this abstract representation helps deepen or clarify their understanding of the operation but you dont need to know it. A final note here if youre wondering how the modulo operation functions with negative numbers or decimals thats a bit outside the scope of this article. For our purposes here well only be dealing with positive integers. Y