本文整理汇总了C#中System.Complex.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Complex.ToString方法的具体用法?C# Complex.ToString怎么用?C# Complex.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Complex
的用法示例。
在下文中一共展示了Complex.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanFormatComplexToString
public void CanFormatComplexToString(double real, double imag, string expected)
{
var numberFormat = NumberFormatInfo.CurrentInfo;
var a = new Complex(real, imag);
Assert.AreEqual(
String.Format(
expected,
numberFormat.NumberDecimalSeparator,
numberFormat.NaNSymbol,
numberFormat.PositiveInfinitySymbol),
a.ToString());
}
示例2: Cyclotomic
public static Complex Cyclotomic(Complex n, Complex z)
{
if (n != Truncate(n)) throw new MathException(n.ToString(), 0, "n doit être entier");
return
Product(
k =>
Pow(z - Pow(Constants.E, (2.0 * Constants.Pi * Constants.I * k) / n),
KroneckerDelta(GCD(k, n), 1)), 1, n);
}
示例3: BetaLn
public static Complex BetaLn(Complex z, Complex w)
{
if (z <= 0.0)
{
throw new MathException(z.ToString(), 0, "z doit être positif.");
}
if (w <= 0.0)
{
throw new MathException(w.ToString(), 0, "w doit être positif.");
}
return LogGamma(z) + LogGamma(w) - LogGamma(z + w);
}
示例4: ToStringTest
public void ToStringTest(double re, double im, string expected)
{
//arrange
Complex c = new Complex(re, im);
//action
string actual = c.ToString(CultureInfo.InvariantCulture);
//assert
actual.Should().Be(expected);
}
示例5: ConvertToString
public void ConvertToString()
{
var c1 = new Complex(1, 2);
var c2 = new Complex(0, 3);
var c3 = new Complex(4, 0);
var c4 = new Complex(4, -5);
var c5 = new Complex(-6, -7);
Assert.AreEqual("1+2i", c1.ToString());
Assert.AreEqual("3i", c2.ToString());
Assert.AreEqual("4", c3.ToString());
Assert.AreEqual("4-5i", c4.ToString());
Assert.AreEqual("-6-7i", c5.ToString());
}