AngouriMath

Navigation

Numbers


← Back to list of classes

Description

Summary

All operations for Number and its derived classes are available from here.
These methods represent the only possible way to explicitly create numeric instances.
It will automatically downcast the result for you,
so
Number.Create(1.0);
is an Integer.
To avoid it, you may temporarily disable it
using var _ = MathS.Settings.DowncastingEnabled.Set(false);
var yourNum = Number.Create(1.0);

and the result will be a Real.

Example

using System;
using System.Numerics;
using AngouriMath;
using PeterO.Numbers;
using static AngouriMath.MathS.Numbers;
using static AngouriMath.MathS;

Entity a1 = 5;
Entity a2 = "5";
Entity a3 = new Complex(5.5, 6.5);
Entity a4 = 6.5m;
Entity a5 = 6.5;
Entity a6 = 6.5f;
Entity a7 = 5.6 + 3 * i;
Entity a8 = EInteger.One;
Entity a9 = ERational.One;
Entity a10 = pi;
Console.WriteLine("---------------");
var n0 = Create(0);
var n1 = Create(0L);
var n2 = Create(new Complex(5.5, 4.75));
var n3 = Create(EInteger.One);
var n4 = CreateRational(4, 5);
var n5 = Create(ERational.One);
var n6 = Create(5.5m);
var n7 = Create(5.5);
var n8 = Create(5.5m, 6.5m);
Console.WriteLine("---------------");
float i0 = (float)FromString("1 + 5").EvalNumerical();
double i1 = (double)FromString("1 + 5").EvalNumerical();
int i2 = (int)FromString("1 + 5").EvalNumerical();
long i3 = (long)FromString("1 + 5").EvalNumerical();
short i4 = (short)FromString("1 + 5").EvalNumerical();
BigInteger i5 = (BigInteger)FromString("1 + 5").EvalNumerical();
Complex i6 = (Complex)FromString("1 + 5").EvalNumerical();
EInteger i7 = ((Entity.Number.Integer)FromString("1 + 5").EvalNumerical()).EInteger;
ERational i8 = ((Entity.Number.Rational)FromString("1 + 5").EvalNumerical()).ERational;
EDecimal i9 = ((Entity.Number.Real)FromString("1 + 5").EvalNumerical()).EDecimal;

Members

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1534 pages online