mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-06 23:03:58 +00:00
Initial commit
This commit is contained in:
parent
c0d4d11b54
commit
0e89590d92
46 changed files with 1741 additions and 0 deletions
27
vscode/Chapter08/WorkingWithNumbers/Program.cs
Normal file
27
vscode/Chapter08/WorkingWithNumbers/Program.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System.Numerics;
|
||||
|
||||
WriteLine("Working with large integers:");
|
||||
WriteLine("-----------------------------------");
|
||||
|
||||
ulong big = ulong.MaxValue;
|
||||
WriteLine($"{big,40:N0}");
|
||||
|
||||
BigInteger bigger =
|
||||
BigInteger.Parse("123456789012345678901234567890");
|
||||
WriteLine($"{bigger,40:N0}");
|
||||
|
||||
WriteLine("Working with complex numbers:");
|
||||
|
||||
Complex c1 = new(real: 4, imaginary: 2);
|
||||
Complex c2 = new(real: 3, imaginary: 7);
|
||||
Complex c3 = c1 + c2;
|
||||
|
||||
// output using default ToString implementation
|
||||
WriteLine($"{c1} added to {c2} is {c3}");
|
||||
|
||||
// output using custom format
|
||||
WriteLine("{0} + {1}i added to {2} + {3}i is {4} + {5}i",
|
||||
c1.Real, c1.Imaginary,
|
||||
c2.Real, c2.Imaginary,
|
||||
c3.Real, c3.Imaginary);
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue