NumberLikeData

public static class NumberLikeData
Represents one of several standard numeric data types. Components which operate on or yield numeric data of various kinds can use this type to avoid unnecessary casting in input or output parameters.

Methods

Cast

#
public static NumberLikeType Cast(object data, out int integer, out double number, out Angle angle, out Complex complex, out BigInteger integerX)
Cast an object to the correct numeric type.
data (object)Data to cast.
integer (out int)Output in case data is a 32-bit integer.
number (out double)Output in case data is a 64-bit decimal or a 32-bit integer, or the radian portion of an angle.
angle (out Angle)Output in case data is a 64-bit angle.
complex (out Complex)Output in case data is a 64-bit complex number.
integerX (out BigInteger)Output in case data is a variable-bit integer.
The type of data.

CastOrConvert

#
public static NumberLikeType CastOrConvert(IEnumerable data, out Array array, out int nullCount, out int nonNumericCount)
Cast or convert a collection of number like data to an array of a single type.
data (IEnumerable)Data to convert.
array (out Array)Array of a specific type.
nullCount (out int)Amount of nulls encountered in data.
nonNumericCount (out int)Amount of non-numeric values encountered in data.
The most common type of data.

CastOrConvert

#
public static NumberLikeType CastOrConvert(object data, out int integer, out double number, out Angle angle, out Complex complex, out BigInteger integerX)
Cast or convert an object to a numeric type if possible.
data (object)Data to cast.
integer (out int)Output in case data is a 32-bit integer.
number (out double)Output in case data is a 64-bit decimal.
angle (out Angle)Output in case data is a 64-bit angle.
complex (out Complex)Output in case data is a 64-bit complex number.
integerX (out BigInteger)Output in case data is a variable-bit integer.
Numeric type, if any.

Convert

#
public static NumberLikeType Convert(object data, out int integer, out double number, out Angle angle, out Complex complex, out BigInteger integerX)
Convert an object to a numeric type if possible. This is a potentially very expensive method to call as it will run through registered type conversions.
data (object)Data to cast.
integer (out int)Output in case data is a 32-bit integer.
number (out double)Output in case data is a 64-bit decimal.
angle (out Angle)Output in case data is a 64-bit angle.
complex (out Complex)Output in case data is a 64-bit complex number.
integerX (out BigInteger)Output in case data is a variable-bit integer.
Numeric type, if any.

IsNumeric

#
public static NumberLikeType IsNumeric(object data)
Check whether a value is a kind of numeric value. This method does not take into account possible type conversions into numeric values.
data (object)Data to check.
Type of numeric, or None is the data is null or not a numeric type.

ToComplex

#
public static Complex ToComplex(NumberLikeType type, int integer, double number, Angle angle, Complex complex, BigInteger integerX)
Create a complex number based on a pre-existing value and a type.
type (NumberLikeType)Argument to use.
integer (int)Integer, only used if type==integer
number (double)Floating point number, only used if type==decimal
angle (Angle)Angle, only used if type==angle
complex (Complex)Complex, returned directly if type==complex
integerX (BigInteger)Big integer, used only if type==bigInteger
Complex number which best approximates the implied numeric value.

ToDouble

#
public static bool ToDouble(object value, out double number)
Try and convert a value into a double.
value (object)Value to convert.
number (out double)Double best describing the value.
True if any conversion was made.

UnifyTypes

#
public static bool UnifyTypes(object a, object b, object c, out object aʹ, out object bʹ, out object cʹ, out NumberLikeType type)
Unify the types of three numberlike values.
a (object)
b (object)
c (object)
aʹ (out object)
bʹ (out object)
cʹ (out object)
type (out NumberLikeType)

UnifyTypes

#
public static bool UnifyTypes(object a, object b, out object aʹ, out object bʹ, out NumberLikeType type)
Unify the types of two numberlike values. This method uses a standard fallback sequence: Integer -> IntegerX -> Decimal -> Complex. And Angle -> Decimal -> Complex
a (object)First value.
b (object)Second value.
aʹ (out object)Unified first value.
bʹ (out object)Unified second value.
type (out NumberLikeType)Unification type.
Pair of unified values and the unified type.