dotnet / dotnet/dotnet-api-docs

Unclear documentation for System.Numerics.Complex Increment and Decrement operators

Open
#11,206 3 comments 0 reactions 0 assignees View on GitHub
area-System.Numerics untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Type of issue

Missing information

### Description

The meaning of `Increment` and `Decrement` in the context of complex numbers is not clear. There is no standard interpretation of these operations such as exists for scalar types.

Testing reveals that the implemented behaviour is to increase or decrease the `Real` part of the complex number. This information should be added explicitly to the documentation to avoid confusion.

For example, it would equally valid to increment or decrement the `Imaginary' part (or both parts) or to create a new instance using the 'FromPolarCoordinates' method and increasing or decreasing the 'Magnitude' by 1.
```
using System.Numerics;

public class Example
{
public static void Main()
{
Complex a = new(1, 2);
Console.WriteLine("Original value : {0}", a);

--a;
Console.WriteLine("Decrement, : {0}", a);

++a;
Console.WriteLine("Increment, : {0}", a);
}
}

// The example displays the following output:
// Original value, a : (1, 2)
// Decrement, a : (0, 2)
// Increment, a : (1, 2)
```

### Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.numerics.complex.op_increment?view=net-9.0

### Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Numerics/Complex.xml

### Document Version Independent Id

972c853b-d3c7-56e6-a473-c4edfb80a625

### Platform Id

39853e0f-4766-3121-6602-6a2cdb8c10bb

### Article author

@dotnet-bot

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.