Skip to content

Commit f620153

Browse files
aaronfrankeBillWagner
authored andcommitted
Rename "modulus" to "remainder" (#4860)
1 parent 830093d commit f620153

File tree

10 files changed

+45
-29
lines changed

10 files changed

+45
-29
lines changed

.openpublishing.redirection.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@
329329
"source_path": "docs/csharp/interop.md",
330330
"redirect_url": "/dotnet/csharp/programming-guide/interop/index"
331331
},
332+
{
333+
"source_path": "docs/csharp/language-reference/operators/modulus-assignment-operator.md",
334+
"redirect_url": "/dotnet/csharp/language-reference/operators/remainder-assignment-operator"
335+
},
336+
{
337+
"source_path": "docs/csharp/language-reference/operators/modulus-operator.md",
338+
"redirect_url": "/dotnet/csharp/language-reference/operators/remainder-operator"
339+
},
332340
{
333341
"source_path": "docs/csharp/namespaces-and-assemblies.md",
334342
"redirect_url": "/dotnet/csharp/programming-guide/namespaces/index"

docs/csharp/language-reference/operators/and-operator.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "& Operator (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
@@ -18,14 +18,14 @@ author: "BillWagner"
1818
ms.author: "wiwagn"
1919
---
2020
# & Operator (C# Reference)
21-
The & operator can function as either a unary or a binary operator.
21+
The `&` operator can function as either a unary or a binary operator.
2222

2323
## Remarks
24-
The unary & operator returns the address of its operand (requires [unsafe](../../../csharp/language-reference/keywords/unsafe.md) context).
24+
The unary `&` operator returns the address of its operand (requires [unsafe](../../../csharp/language-reference/keywords/unsafe.md) context).
2525

26-
Binary & operators are predefined for the integral types and `bool`. For integral types, & computes the logical bitwise AND of its operands. For `bool` operands, & computes the logical AND of its operands; that is, the result is `true` if and only if both its operands are `true`.
26+
Binary `&` operators are predefined for the integral types and `bool`. For integral types, & computes the logical bitwise AND of its operands. For `bool` operands, & computes the logical AND of its operands; that is, the result is `true` if and only if both its operands are `true`.
2727

28-
The `&` operator evaluates both operators regardless of the first one's value. For example:
28+
The binary `&` operator evaluates both operators regardless of the first one's value, in contrast to the [conditional AND operator](../../../csharp/language-reference/operators/conditional-and-operator.md) `&&`. For example:
2929

3030
[!code-csharp[csRefOperators#37](../../../csharp/language-reference/operators/codesnippet/CSharp/and-operator_1.cs)]
3131

docs/csharp/language-reference/operators/division-operator.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "/ Operator (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
@@ -16,12 +16,16 @@ author: "BillWagner"
1616
ms.author: "wiwagn"
1717
---
1818
# / Operator (C# Reference)
19-
The division operator (`/`) divides its first operand by its second operand. All numeric types have predefined division operators.
19+
The division operator (`/`) divides its first operand by its second operand. All numeric types have predefined division operators.
2020

2121
## Remarks
2222
User-defined types can overload the `/` operator (see [operator](../../../csharp/language-reference/keywords/operator.md)). An overload of the `/` operator implicitly overloads the [/= operator](division-assignment-operator.md).
2323

24-
When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2. To determine the remainder of 7 / 3, use the remainder operator ([%](../../../csharp/language-reference/operators/modulus-operator.md)). To obtain a quotient as a rational number or fraction, give the dividend or divisor type `float` or type `double`. You can assign the type implicitly if you express the dividend or divisor as a decimal by putting a digit to the right side of the decimal point, as the following example shows.
24+
When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2. This is not to be confused with floored division, as the `/` operator rounds towards zero: -7 / 3 is -2.
25+
26+
To obtain a quotient as a rational number, use the `float`, `double`, or `decimal` types. There are many ways to convert between [built in numeric types](../../../csharp/language-reference/keywords/reference-tables-for-types.md).
27+
28+
To determine the remainder, use the [remainder operator](../../../csharp/language-reference/operators/remainder-operator.md) `%`.
2529

2630
## Example
2731
[!code-csharp[csRefOperators#42](../../../csharp/language-reference/operators/codesnippet/CSharp/division-operator_1.cs)]

docs/csharp/language-reference/operators/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "C# Operators"
3-
ms.date: 03/09/2017
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
@@ -96,7 +96,7 @@ C# provides many operators, which are symbols that specify which operations (mat
9696

9797
[x / y](../../../csharp/language-reference/operators/division-operator.md) – division. If the operands are integers, the result is an integer truncated toward zero (for example, `-7 / 2 is -3`).
9898

99-
[x % y](../../../csharp/language-reference/operators/modulus-operator.md)modulus. If the operands are integers, this returns the remainder of dividing x by y. If `q = x / y` and `r = x % y`, then `x = q * y + r`.
99+
[x % y](../../../csharp/language-reference/operators/remainder-operator.md)remainder. If the operands are integers, this returns the remainder of dividing x by y. If `q = x / y` and `r = x % y`, then `x = q * y + r`.
100100

101101
## Additive Operators
102102
These operators have higher precedence than the next section and lower precedence than the previous section.
@@ -182,7 +182,7 @@ C# provides many operators, which are symbols that specify which operations (mat
182182

183183
[x /= y](../../../csharp/language-reference/operators/division-assignment-operator.md) – division assignment. Divide the value of `x` by the value of `y`, store the result in `x`, and return the new value.
184184

185-
[x %= y](../../../csharp/language-reference/operators/modulus-assignment-operator.md)modulus assignment. Divide the value of `x` by the value of `y`, store the remainder in `x`, and return the new value.
185+
[x %= y](../../../csharp/language-reference/operators/remainder-assignment-operator.md)remainder assignment. Divide the value of `x` by the value of `y`, store the remainder in `x`, and return the new value.
186186

187187
[x &= y](../../../csharp/language-reference/operators/and-assignment-operator.md) – AND assignment. AND the value of `y` with the value of `x`, store the result in `x`, and return the new value.
188188

docs/csharp/language-reference/operators/multiplication-operator.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "* Operator (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
@@ -16,11 +16,11 @@ author: "BillWagner"
1616
ms.author: "wiwagn"
1717
---
1818
# * Operator (C# Reference)
19-
The multiplication operator (`*`), which computes the product of its operands. Also, the dereference operator, which allows reading and writing to a pointer.
19+
The multiplication operator (`*`) computes the product of its operands. All numeric types have predefined multiplication operators.
20+
21+
`*` also serves as the dereference operator, which allows reading and writing to a pointer.
2022

2123
## Remarks
22-
All numeric types have predefined multiplication operators.
23-
2424
The `*` operator is also used to declare pointer types and to dereference pointers. This operator can only be used in unsafe contexts, denoted by the use of the [unsafe](../../../csharp/language-reference/keywords/unsafe.md) keyword, and requiring the [/unsafe](../../../csharp/language-reference/compiler-options/unsafe-compiler-option.md) compiler option. The dereference operator is also known as the indirection operator.
2525

2626
User-defined types can overload the binary `*` operator (see [operator](../../../csharp/language-reference/keywords/operator.md)). When a binary operator is overloaded, the corresponding assignment operator, if any, is also implicitly overloaded.

docs/csharp/language-reference/operators/modulus-assignment-operator.md renamed to docs/csharp/language-reference/operators/remainder-assignment-operator.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
title: "%= Operator (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
77
ms.topic: "article"
88
f1_keywords:
99
- "%=_CSharpKeyword"
1010
helpviewer_keywords:
11-
- "modulus assignment operator (=%) [C#]"
12-
- "%= assignment operator (modulus assignment) [C#]"
11+
- "remainder assignment operator (%=) [C#]"
12+
- "%= assignment operator (remainder assignment) [C#]"
1313
ms.assetid: 47e5f068-1d97-4010-bd3b-e21b5d3a77f5
1414
caps.latest.revision: 20
1515
author: "BillWagner"
@@ -31,9 +31,9 @@ x %= y
3131
x = x % y
3232
```
3333

34-
except that `x` is only evaluated once. The [% operator](../../../csharp/language-reference/operators/modulus-operator.md) is predefined for numeric types to compute the remainder after division.
34+
except that `x` is only evaluated once. The [% operator](../../../csharp/language-reference/operators/remainder-operator.md) is predefined for numeric types to compute the remainder after division.
3535

36-
The `%=` operator cannot be overloaded directly, but user-defined types can overload the [% operator](../../../csharp/language-reference/operators/modulus-operator.md) (see [operator (C# Reference)](../../../csharp/language-reference/keywords/operator.md)).
36+
The `%=` operator cannot be overloaded directly, but user-defined types can overload the [% operator](../../../csharp/language-reference/operators/remainder-operator.md) (see [operator (C# Reference)](../../../csharp/language-reference/keywords/operator.md)).
3737

3838
## Example
3939
[!code-csharp[csRefOperators#4](../../../csharp/language-reference/operators/codesnippet/CSharp/modulus-assignment-operator_1.cs)]

docs/csharp/language-reference/operators/modulus-operator.md renamed to docs/csharp/language-reference/operators/remainder-operator.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
---
22
title: "% Operator (C# Reference)"
3-
ms.date: 07/20/2015
3+
ms.date: 04/04/2018
44
ms.prod: .net
55
ms.technology:
66
- "devlang-csharp"
77
ms.topic: "article"
88
f1_keywords:
99
- "%_CSharpKeyword"
1010
helpviewer_keywords:
11-
- "modulus operator [C#]"
11+
- "remainder operator [C#]"
1212
- "% operator [C#]"
1313
ms.assetid: 3b74f4f9-fd9c-45e7-84fa-c8d71a0dfad7
1414
caps.latest.revision: 15
1515
author: "BillWagner"
1616
ms.author: "wiwagn"
1717
---
1818
# % Operator (C# Reference)
19-
The `%` operator computes the remainder after dividing its first operand by its second. All numeric types have predefined remainder operators.
19+
The remainder operator (`%`) computes the remainder after dividing its first operand by its second. All numeric types have predefined remainder operators.
2020

2121
## Remarks
22+
The formula `a % b` will always return a value on the range `(-b, b)`, exclusive (it can never return `b` or `-b`), keeping the sign of the dividend. For integer division, the remainder operator satisfies the rule `a % b = a - (a / b) * b`.
23+
24+
This is not to be confused with canonical modulus, which satisfies a similar rule but with floored division and returns values on the range `[0, b)`. C# does not have an operator for canonical modulus. However, the behavior is the same for positive dividends.
25+
2226
User-defined types can overload the `%` operator (see [operator](../../../csharp/language-reference/keywords/operator.md)). When a binary operator is overloaded, the corresponding assignment operator, if any, is also implicitly overloaded.
2327

2428
## Example
25-
[!code-csharp[csRefOperators#9](../../../csharp/language-reference/operators/codesnippet/CSharp/modulus-operator_1.cs)]
29+
[!code-csharp[csRefOperators#9](../../../csharp/language-reference/operators/codesnippet/CSharp/remainder-operator_1.cs)]
2630

2731
## Comments
2832
Note the round-off errors associated with the double type.

docs/fsharp/language-reference/symbol-and-operator-reference/arithmetic-operators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn about the arithmetic operators that are available in the F# p
44
keywords: visual f#, f#, functional programming
55
author: cartermp
66
ms.author: phcart
7-
ms.date: 05/16/2016
7+
ms.date: 04/04/2018
88
ms.topic: language-reference
99
ms.prod: .net
1010
ms.technology: devlang-fsharp
@@ -25,7 +25,7 @@ The following table summarizes the binary arithmetic operators that are availabl
2525
|`-` (subtraction, minus)|Unchecked. Possible underflow condition when unsigned types are subtracted, or when floating-point values are too small to be represented by the type.|
2626
|`*` (multiplication, times)|Unchecked. Possible overflow condition when numbers are multiplied and the product exceeds the maximum absolute value supported by the type.|
2727
|`/` (division, divided by)|Division by zero causes a <xref:System.DivideByZeroException> for integral types. For floating-point types, division by zero gives you the special floating-point values `+Infinity` or `-Infinity`. There is also a possible underflow condition when a floating-point number is too small to be represented by the type.|
28-
|`%` (modulus, mod)|Returns the remainder of a division operation. The sign of the result is the same as the sign of the first operand.|
28+
|`%` (remainder, rem)|Returns the remainder of a division operation. The sign of the result is the same as the sign of the first operand.|
2929
|`**` (exponentiation, to the power of)|Possible overflow condition when the result exceeds the maximum absolute value for the type.<br /><br />The exponentiation operator works only with floating-point types.|
3030

3131
## Summary of Unary Arithmetic Operators

docs/fsharp/language-reference/symbol-and-operator-reference/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn about the symbols and operators that are used in the F# progr
44
keywords: visual f#, f#, functional programming
55
author: cartermp
66
ms.author: phcart
7-
ms.date: 05/16/2016
7+
ms.date: 04/04/2018
88
ms.topic: language-reference
99
ms.prod: .net
1010
ms.technology: devlang-fsharp
@@ -30,9 +30,9 @@ The following table describes symbols used in the F# language, provides links to
3030
|`"""`|[Strings](../strings.md)|Delimits a verbatim text string. Differs from `@"..."` in that a you can indicate a quotation mark character by using a single quote in the string.|
3131
|`#`|[Compiler Directives](../compiler-directives.md)<br /><br />[Flexible Types](../flexible-types.md)|<ul><li>Prefixes a preprocessor or compiler directive, such as `#light`.<br /></li><li>When used with a type, indicates a *flexible type*, which refers to a type or any one of its derived types.<br /></li><ul/>|
3232
|`$`|No more information available.|<ul><li>Used internally for certain compiler-generated variable and function names.<br /></li><ul/>|
33-
|`%`|[Arithmetic Operators](arithmetic-operators.md)<br /><br />[Code Quotations](../code-quotations.md)|<ul><li>Computes the integer modulus.<br /></li><li>Used for splicing expressions into typed code quotations.<br /></li><ul/>|
33+
|`%`|[Arithmetic Operators](arithmetic-operators.md)<br /><br />[Code Quotations](../code-quotations.md)|<ul><li>Computes the integer remainder.<br /></li><li>Used for splicing expressions into typed code quotations.<br /></li><ul/>|
3434
|`%%`|[Code Quotations](../code-quotations.md)|<ul><li>Used for splicing expressions into untyped code quotations.<br /></li><ul/>|
35-
|`%?`|[Nullable Operators](nullable-operators.md)|<ul><li>Computes the integer modulus, when the right side is a nullable type.<br /></li><ul/>|
35+
|`%?`|[Nullable Operators](nullable-operators.md)|<ul><li>Computes the integer remainder, when the right side is a nullable type.<br /></li><ul/>|
3636
|`&`|[Match Expressions](../match-expressions.md)|<ul><li>Computes the address of a mutable value, for use when interoperating with other languages.<br /></li><li>Used in AND patterns.<br /></li><ul/>|
3737
|`&&`|[Boolean Operators](boolean-operators.md)|<ul><li>Computes the Boolean AND operation.<br /></li><ul/>|
3838
|`&&&`|[Bitwise Operators](bitwise-operators.md)|<ul><li>Computes the bitwise AND operation.<br /></li><ul/>|

0 commit comments

Comments
 (0)