Struct Numeric
Represents a number, either decimal or not, with arbitrary precision.
Note: This struct is intended to be used by the node system when implementing your own Node. Usage outside that context is not recommended due to conversion overhead.
public readonly struct Numeric : IComparable<Numeric>, IConvertible
- Implements
Constructors
Numeric(byte)
public Numeric(byte value)
Parameters
valuebyte
Numeric(double)
public Numeric(double value)
Parameters
valuedouble
Numeric(int)
public Numeric(int value)
Parameters
valueint
Numeric(long)
public Numeric(long value)
Parameters
valuelong
Numeric(object?)
Creates a new instance of Numeric from an object
public Numeric(object? pathValue)
Parameters
pathValueobject
Numeric(float)
public Numeric(float value)
Parameters
valuefloat
Methods
CompareTo(Numeric)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
public int CompareTo(Numeric other)
Parameters
otherNumericAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
Equals(Numeric)
Indicates whether this instance and a specified numeric are equal
public bool Equals(Numeric other)
Parameters
otherNumericThe numeric to compare with the current instance
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetTypeCode()
Returns the TypeCode for this instance.
public TypeCode GetTypeCode()
Returns
- TypeCode
The enumerated constant that is the TypeCode of the class or value type that implements this interface.
IsTypeCompatible(Type?)
Returns a boolean indicating whether the provided type can be used as a Numeric.
public static bool IsTypeCompatible(Type? type)
Parameters
typeType
Returns
ToBoolean(IFormatProvider?)
Converts the value of this instance to an equivalent Boolean value using the specified culture-specific formatting information.
public bool ToBoolean(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- bool
A Boolean value equivalent to the value of this instance.
ToByte(IFormatProvider?)
Converts the value of this instance to an equivalent 8-bit unsigned integer using the specified culture-specific formatting information.
public byte ToByte(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- byte
An 8-bit unsigned integer equivalent to the value of this instance.
ToChar(IFormatProvider?)
Converts the value of this instance to an equivalent Unicode character using the specified culture-specific formatting information.
public char ToChar(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- char
A Unicode character equivalent to the value of this instance.
ToDateTime(IFormatProvider?)
Converts the value of this instance to an equivalent DateTime using the specified culture-specific formatting information.
public DateTime ToDateTime(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToDecimal(IFormatProvider?)
Converts the value of this instance to an equivalent decimal number using the specified culture-specific formatting information.
public decimal ToDecimal(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToDouble(IFormatProvider?)
Converts the value of this instance to an equivalent double-precision floating-point number using the specified culture-specific formatting information.
public double ToDouble(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- double
A double-precision floating-point number equivalent to the value of this instance.
ToInt16(IFormatProvider?)
Converts the value of this instance to an equivalent 16-bit signed integer using the specified culture-specific formatting information.
public short ToInt16(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- short
An 16-bit signed integer equivalent to the value of this instance.
ToInt32(IFormatProvider?)
Converts the value of this instance to an equivalent 32-bit signed integer using the specified culture-specific formatting information.
public int ToInt32(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- int
An 32-bit signed integer equivalent to the value of this instance.
ToInt64(IFormatProvider?)
Converts the value of this instance to an equivalent 64-bit signed integer using the specified culture-specific formatting information.
public long ToInt64(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- long
An 64-bit signed integer equivalent to the value of this instance.
ToSByte(IFormatProvider?)
Converts the value of this instance to an equivalent 8-bit signed integer using the specified culture-specific formatting information.
public sbyte ToSByte(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- sbyte
An 8-bit signed integer equivalent to the value of this instance.
ToSingle(IFormatProvider?)
Converts the value of this instance to an equivalent single-precision floating-point number using the specified culture-specific formatting information.
public float ToSingle(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- float
A single-precision floating-point number equivalent to the value of this instance.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(IFormatProvider?)
Converts the value of this instance to an equivalent string using the specified culture-specific formatting information.
public string ToString(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
ToType(Type, IFormatProvider?)
Converts the value of this instance to an object of the specified Type that has an equivalent value, using the specified culture-specific formatting information.
public object ToType(Type conversionType, IFormatProvider? provider)
Parameters
conversionTypeTypeThe Type to which the value of this instance is converted.
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- object
An object instance of type
conversionTypewhose value is equivalent to the value of this instance.
ToUInt16(IFormatProvider?)
Converts the value of this instance to an equivalent 16-bit unsigned integer using the specified culture-specific formatting information.
public ushort ToUInt16(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- ushort
An 16-bit unsigned integer equivalent to the value of this instance.
ToUInt32(IFormatProvider?)
Converts the value of this instance to an equivalent 32-bit unsigned integer using the specified culture-specific formatting information.
public uint ToUInt32(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- uint
An 32-bit unsigned integer equivalent to the value of this instance.
ToUInt64(IFormatProvider?)
Converts the value of this instance to an equivalent 64-bit unsigned integer using the specified culture-specific formatting information.
public ulong ToUInt64(IFormatProvider? provider)
Parameters
providerIFormatProviderAn IFormatProvider interface implementation that supplies culture-specific formatting information.
Returns
- ulong
An 64-bit unsigned integer equivalent to the value of this instance.
TryParse(string?, out Numeric)
Converts the string representation of a number into a numeric. A return value indicates whether the conversion succeeded or failed.
public static bool TryParse(string? s, out Numeric result)
Parameters
sstringA string representing a number to convert.
resultNumericWhen this method returns, contains numeric equivalent to the numeric value or symbol contained in
s, if the conversion succeeded, or zero if the conversion failed.
Returns
Operators
operator +(Numeric, Numeric)
public static Numeric operator +(Numeric a, Numeric b)
Parameters
Returns
operator --(Numeric)
public static Numeric operator --(Numeric a)
Parameters
aNumeric
Returns
operator /(Numeric, Numeric)
public static Numeric operator /(Numeric a, Numeric b)
Parameters
Returns
operator ==(Numeric, Numeric)
public static bool operator ==(Numeric left, Numeric right)
Parameters
Returns
operator >(Numeric, Numeric)
public static bool operator >(Numeric a, Numeric b)
Parameters
Returns
operator >=(Numeric, Numeric)
public static bool operator >=(Numeric left, Numeric right)
Parameters
Returns
implicit operator byte(Numeric)
public static implicit operator byte(Numeric p)
Parameters
pNumeric
Returns
implicit operator decimal(Numeric)
public static implicit operator decimal(Numeric p)
Parameters
pNumeric
Returns
implicit operator double(Numeric)
public static implicit operator double(Numeric p)
Parameters
pNumeric
Returns
implicit operator int(Numeric)
public static implicit operator int(Numeric p)
Parameters
pNumeric
Returns
implicit operator long(Numeric)
public static implicit operator long(Numeric p)
Parameters
pNumeric
Returns
implicit operator float(Numeric)
public static implicit operator float(Numeric p)
Parameters
pNumeric
Returns
implicit operator Numeric(byte)
public static implicit operator Numeric(byte b)
Parameters
bbyte
Returns
implicit operator Numeric(double)
public static implicit operator Numeric(double d)
Parameters
ddouble
Returns
implicit operator Numeric(int)
public static implicit operator Numeric(int i)
Parameters
iint
Returns
implicit operator Numeric(float)
public static implicit operator Numeric(float f)
Parameters
ffloat
Returns
operator ++(Numeric)
public static Numeric operator ++(Numeric a)
Parameters
aNumeric
Returns
operator !=(Numeric, Numeric)
public static bool operator !=(Numeric left, Numeric right)
Parameters
Returns
operator <(Numeric, Numeric)
public static bool operator <(Numeric a, Numeric b)
Parameters
Returns
operator <=(Numeric, Numeric)
public static bool operator <=(Numeric left, Numeric right)
Parameters
Returns
operator %(Numeric, Numeric)
public static Numeric operator %(Numeric a, Numeric b)
Parameters
Returns
operator *(Numeric, Numeric)
public static Numeric operator *(Numeric a, Numeric b)
Parameters
Returns
operator -(Numeric, Numeric)
public static Numeric operator -(Numeric a, Numeric b)
Parameters
Returns
operator -(Numeric)
public static Numeric operator -(Numeric a)
Parameters
aNumeric
Returns
operator +(Numeric)
public static Numeric operator +(Numeric a)
Parameters
aNumeric