diff --git a/programming/README.md b/programming/README.md new file mode 100644 index 00000000..bc618b8f --- /dev/null +++ b/programming/README.md @@ -0,0 +1,3 @@ +# Programming + +Docs on programming topics diff --git a/programming/config.json b/programming/config.json new file mode 100644 index 00000000..665c43e4 --- /dev/null +++ b/programming/config.json @@ -0,0 +1,23 @@ +[ + { + "uuid": "1a737701-e2f7-4021-9057-a0faf4738740", + "slug": "APEX", + "path": "programming/README.md", + "title": "Programming docs", + "blurb": "Docs on programming topics" + }, + { + "uuid": "54390764-ef34-4385-b714-ab2851bdd814", + "slug": "reaminder", + "path": "programming/operators/README.md", + "title": "Operators", + "blurb": "Docs on operators" + }, + { + "uuid": "f1848a5a-593d-411f-9d44-4d4849690e1e", + "slug": "remainder", + "path": "programming/operators/remainder.md", + "title": "Remainder", + "blurb": "The remainder operators" + }, +] diff --git a/programming/operators/README.md b/programming/operators/README.md new file mode 100644 index 00000000..66a6f3cf --- /dev/null +++ b/programming/operators/README.md @@ -0,0 +1,3 @@ +# Operators + +Docs on operators diff --git a/programming/operators/remainder.md b/programming/operators/remainder.md new file mode 100644 index 00000000..fa5aa6de --- /dev/null +++ b/programming/operators/remainder.md @@ -0,0 +1,30 @@ +# Remainder + +In mathematics, the **remainder** is the amount "left over" after performing some computation. +For example, the remainder of `5 / 3` is `2`. + +Many programming languages use the percentage sign (`%`) as an operator to calculate the remainder. +For example, this is valid code in Javascript and Python: +```javascript +5 % 3 == 2 +``` + +Remainders can often be calculated on both integers and floating point numbers. +For example, +```javascript +5.3 % 3 == 2.3 +``` + +When working with negative numbers, the result always has the same sign as the dividend (the number on the left hand side that is being divided). +For example: +```javascript +-5 % 3 == -2 +5 % -3 == 2 +-5 % -3 == -2 +``` + +Some languages use the `%` operator for the calculating the modulus, not the remainder. +This treats negative numbers differently. +You can learn more about this [on Wikipedia](https://en.wikipedia.org/wiki/Modulo). + +