Skip to content

Commit 6110224

Browse files
Copilotgewarren
andcommitted
Initial setup: Identify and reproduce the negative imaginary part formatting issue
Co-authored-by: gewarren <[email protected]>
1 parent 1b0c531 commit 6110224

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CustomFormatEx.Run();
1+
TestNegativeImaginary.Run();

docs/fundamentals/runtime-libraries/snippets/System.Numerics/Complex/Overview/csharp/Project.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net9</TargetFrameworks>
5+
<TargetFrameworks>net8.0</TargetFrameworks>
66
</PropertyGroup>
77

88
</Project>

docs/fundamentals/runtime-libraries/snippets/System.Numerics/Complex/Overview/csharp/customfmt1.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,30 @@ public static void Run()
7373
// Custom formatting with I0: 12 + 15i
7474
// Custom formatting with J3: 12.100 + 15.400j
7575
// </Snippet4>
76+
77+
public class TestNegativeImaginary
78+
{
79+
public static void Run()
80+
{
81+
// Test with positive imaginary part
82+
Complex c1 = new(12.1, 15.4);
83+
Console.WriteLine("=== Positive imaginary part ===");
84+
Console.WriteLine($"Complex number: {c1}");
85+
Console.WriteLine($"Custom formatting with I0: {string.Format(new ComplexFormatter(), "{0:I0}", c1)}");
86+
Console.WriteLine($"Custom formatting with J3: {string.Format(new ComplexFormatter(), "{0:J3}", c1)}");
87+
88+
// Test with negative imaginary part - this should demonstrate the bug
89+
Complex c2 = new(12.1, -15.4);
90+
Console.WriteLine("\n=== Negative imaginary part ===");
91+
Console.WriteLine($"Complex number: {c2}");
92+
Console.WriteLine($"Custom formatting with I0: {string.Format(new ComplexFormatter(), "{0:I0}", c2)}");
93+
Console.WriteLine($"Custom formatting with J3: {string.Format(new ComplexFormatter(), "{0:J3}", c2)}");
94+
95+
// Test with zero imaginary part
96+
Complex c3 = new(12.1, 0.0);
97+
Console.WriteLine("\n=== Zero imaginary part ===");
98+
Console.WriteLine($"Complex number: {c3}");
99+
Console.WriteLine($"Custom formatting with I0: {string.Format(new ComplexFormatter(), "{0:I0}", c3)}");
100+
Console.WriteLine($"Custom formatting with J3: {string.Format(new ComplexFormatter(), "{0:J3}", c3)}");
101+
}
102+
}

docs/fundamentals/runtime-libraries/snippets/System.Numerics/Complex/Overview/vb/Project.vbproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net9</TargetFrameworks>
5+
<TargetFrameworks>net8.0</TargetFrameworks>
66
</PropertyGroup>
77

88
</Project>

0 commit comments

Comments
 (0)