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

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

CastOrConvert

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

CastOrConvert

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

Convert

#
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.
public static NumberLikeType Convert(
data,
Data to cast.
out int
integer,
Output in case data is a 32-bit integer.
out double
number,
Output in case data is a 64-bit decimal.
out Angle
angle,
Output in case data is a 64-bit angle.
out Complex
complex,
Output in case data is a 64-bit complex number.
integerX
Output in case data is a variable-bit integer.
)
Numeric type, if any.

IsNumeric

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

ToComplex

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

ToDouble

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

UnifyTypes

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

UnifyTypes

#
Unify the types of two numberlike values. This method uses a standard fallback sequence: Integer -> IntegerX -> Decimal -> Complex. And Angle -> Decimal -> Complex
public static bool UnifyTypes(object a, object b, out object aʹ, out object bʹ, out NumberLikeType type)
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.