Class VBNumericType
Represents any numeric data type mentioned in the MS-VBAL language specifications.
public abstract record VBNumericType : VBIntrinsicType, IEquatable<VBType>, IEquatable<VBIntrinsicType>, INumericType, IEquatable<VBNumericType>
- Inheritance
-
VBNumericType
- Implements
- Derived
- Inherited Members
Constructors
VBNumericType(string, Type)
Represents any numeric data type mentioned in the MS-VBAL language specifications.
protected VBNumericType(string Name, Type ManagedType)
Parameters
Properties
ManagedMaxValue
Gets the maximum representable managed (.net) value for this data type.
public abstract double ManagedMaxValue { get; }
Property Value
ManagedMinValue
Gets the minimum representable managed (.net) value for this data type.
public abstract double ManagedMinValue { get; }
Property Value
Methods
BankersRounding(VBNumericTypedValue)
Implements MS-VBAL 5.5.1.2.1.1 Banker's Rounding. A midpoint rounding scheme also known as "round-to-even" rounds to the nearest rounded value such that the least-significant digit is even.
public static int BankersRounding(VBNumericTypedValue value)
Parameters
valueVBNumericTypedValueThe numeric value to be rounded.
Returns
BankersRounding(double)
Implements MS-VBAL 5.5.1.2.1.1 Banker's Rounding. A midpoint rounding scheme also known as "round-to-even" rounds to the nearest rounded value such that the least-significant digit is even.
public static int BankersRounding(double value)
Parameters
valuedoubleThe floating-point numeric value to be rounded.
Returns
CreateValue(double)
Creates a value of this numeric type holding value, converted to this
type's managed representation (banker's rounding for integral targets, as per Convert).
public abstract VBNumericTypedValue CreateValue(double value)
Parameters
valuedouble
Returns
IsWithinRange(double, VBNumericType)
A helper function to test if a given source numeric value is within the range of a destination data type.
public static bool IsWithinRange(double source, VBNumericType destination)
Parameters
sourcedoubleThe managed (.net) numeric source value to validate.
destinationVBNumericTypeThe data type to check conversion eligibility against.
Returns
- bool
trueif the value can legally be used with the destination type,false otherwise.
Remarks
If this function returns false, the caller should throw a VBRuntimeErrorOverflowException.