AngouriMath
ToNumber
Method with 8 overloads
ToNumber(PeterO.Numbers.EDecimal)
Summary
Returns
AM's RealExample
Console.WriteLine(EDecimal.FromString("0.1").ToNumber());
Prints
1/10ToNumber(PeterO.Numbers.EInteger)
Summary
Returns
AM's IntegerExample
Console.WriteLine(EInteger.FromString("2").Pow(128).ToNumber());
Prints
340282366920938463463374607431768211456ToNumber(System.Decimal)
Summary
Converts an Decimal into an AM's understandable Real which can be hung with others
Returns
AM's RealExample
Decimal is a decimal type, so a decimal literal survives it exactly
where the same literal as a Double does not:
Console.WriteLine(0.1m.ToNumber()); Console.WriteLine(0.1.ToNumber());
Prints
1/10 0.1000000000000000055511151231257827021181583404541015625ToNumber(System.Double)
Summary
Converts an Double into an AM's understandable Real which can be hung with others
Returns
AM's RealExample
As for Single, the binary value is kept exactly; a value that a
Double does represent exactly comes back as a rational:
Console.WriteLine(0.1.ToNumber()); Console.WriteLine(0.5.ToNumber());
Prints
0.1000000000000000055511151231257827021181583404541015625 1/2ToNumber(System.Int32)
Summary
Converts an Int32 into an AM's understandable Integer which can be hung with others
Returns
AM's IntegerExample
Arithmetic on the result is exact, so a quotient of two integers is a rational
rather than a rounded or floating result:
Console.WriteLine(5.ToNumber() / 2.ToNumber()); Console.WriteLine((5.ToNumber() / 2.ToNumber()).GetType().Name);
Prints
5/2 RationalToNumber(System.Int64)
Summary
Converts an Int64 into an AM's understandable Integer which can be hung with others
Returns
AM's IntegerExample
Once converted the value no longer overflows, so a product that does not fit into a
Int64 is still exact:
Console.WriteLine(long.MaxValue.ToNumber()); Console.WriteLine((long.MaxValue.ToNumber() * long.MaxValue.ToNumber()).Evaled);
Prints
9223372036854775807 85070591730234615847396907784232501249ToNumber(System.Numerics.Complex)
Summary
Converts Numerics's Complex into an AM's understandable Complex which can be hung with others
Returns
AM's ComplexExample
var z = new System.Numerics.Complex(3, 4).ToNumber(); Console.WriteLine(z); Console.WriteLine(z.Abs().Evaled);
Prints
3 + 4i 5ToNumber(System.Single)
Summary
Converts an Single into an AM's understandable Real which can be hung with others
Returns
AM's RealExample
The conversion is exact, which means it keeps the value the Single actually holds rather than the decimal literal it was written as:
Console.WriteLine(0.1f.ToNumber());
Prints
0.100000001490116119384765625
Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 4378 pages online