Struct MassValue
- Namespace
- xFunc.Maths.Expressions.Units.MassUnits
- Assembly
- xFunc.Maths.dll
Represents a number with unit.
public readonly struct MassValue : IEquatable<MassValue>, IComparable<MassValue>, IComparable
- Implements
- Inherited Members
Constructors
MassValue(NumberValue, MassUnit)
Initializes a new instance of the MassValue struct.
public MassValue(NumberValue value, MassUnit unit)
Parameters
value
NumberValueThe value.
unit
MassUnitThe unit of number.
Properties
Sign
Gets an integer that indicates the sign of a double-precision floating-point number.
public double Sign { get; }
Property Value
Unit
Gets a unit.
public MassUnit Unit { get; }
Property Value
Value
Gets a value.
public NumberValue Value { get; }
Property Value
Methods
Abs(MassValue)
Returns the absolute value of a specified value.
public static MassValue Abs(MassValue value)
Parameters
value
MassValueThe value.
Returns
- MassValue
The power value,
x
, that such that 0 ≤x
≤MaxValue
.
AsExpression()
public Mass AsExpression()
Returns
- Mass
The mass number.
Ceiling(MassValue)
Returns the smallest integral value that is greater than or equal to the specified value.
public static MassValue Ceiling(MassValue value)
Parameters
value
MassValueThe value.
Returns
- MassValue
The smallest integral value.
CompareTo(object?)
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(object? obj)
Parameters
obj
objectAn 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 obj
in the sort order.Zero This instance occurs in the same position in the sort order as obj
.Greater than zero This instance follows obj
in the sort order.
Exceptions
- ArgumentException
obj
is not the same type as this instance.
CompareTo(MassValue)
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(MassValue other)
Parameters
other
MassValueAn 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 other
in the sort order.Zero This instance occurs in the same position in the sort order as other
.Greater than zero This instance follows other
in the sort order.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
Equals(MassValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(MassValue other)
Parameters
other
MassValueAn object to compare with this object.
Returns
Floor(MassValue)
Returns the largest integral value less than or equal to the specified value number.
public static MassValue Floor(MassValue value)
Parameters
value
MassValueThe value.
Returns
- MassValue
The largest integral value.
Frac(MassValue)
Returns the fractional part of the value number.
public static MassValue Frac(MassValue value)
Parameters
value
MassValueThe value number.
Returns
- MassValue
The fractional part.
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.
Gram(double)
Creates the MassValue struct with Gram
unit.
public static MassValue Gram(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Gram(NumberValue)
Creates the MassValue struct with Gram
unit.
public static MassValue Gram(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Kilogram(double)
Creates the MassValue struct with Kilogram
unit.
public static MassValue Kilogram(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Kilogram(NumberValue)
Creates the MassValue struct with Kilogram
unit.
public static MassValue Kilogram(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Milligram(double)
Creates the MassValue struct with Milligram
unit.
public static MassValue Milligram(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Milligram(NumberValue)
Creates the MassValue struct with Milligram
unit.
public static MassValue Milligram(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Ounce(double)
Creates the MassValue struct with Ounce
unit.
public static MassValue Ounce(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Ounce(NumberValue)
Creates the MassValue struct with Ounce
unit.
public static MassValue Ounce(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Pound(double)
Creates the MassValue struct with Pound
unit.
public static MassValue Pound(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Pound(NumberValue)
Creates the MassValue struct with Pound
unit.
public static MassValue Pound(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Round(MassValue, NumberValue)
Rounds a double-precision floating-point value to a specified number of fractional digits, and uses the specified rounding convention for midpoint values.
public static MassValue Round(MassValue massValue, NumberValue digits)
Parameters
massValue
MassValueThe number.
digits
NumberValueThe number of fractional digits in the return value.
Returns
- MassValue
The number nearest to
massValue
that has a number of fractional digits equal todigits
. If value has fewer fractional digits thandigits
,massValue
is returned unchanged.
To(MassUnit)
Convert to the newUnit
unit.
public MassValue To(MassUnit newUnit)
Parameters
newUnit
MassUnitThe new unit.
Returns
- MassValue
The value in the new unit.
ToGram()
Converts the value to the gram unit.
public MassValue ToGram()
Returns
- MassValue
The value in gram unit.
ToKilogram()
Converts the value to the kilogram unit.
public MassValue ToKilogram()
Returns
- MassValue
The value in kilogram unit.
ToMilligram()
Converts the value to the milligram unit.
public MassValue ToMilligram()
Returns
- MassValue
The value in milligram unit.
ToOunce()
Converts the value to the ounce unit.
public MassValue ToOunce()
Returns
- MassValue
The value in ounce unit.
ToPound()
Converts the value to the pound unit.
public MassValue ToPound()
Returns
- MassValue
The value in pound unit.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToTonne()
Converts the value to the tonne unit.
public MassValue ToTonne()
Returns
- MassValue
The value in tonne unit.
Tonne(double)
Creates the MassValue struct with Tonne
unit.
public static MassValue Tonne(double value)
Parameters
value
doubleThe value.
Returns
- MassValue
The mass value.
Tonne(NumberValue)
Creates the MassValue struct with Tonne
unit.
public static MassValue Tonne(NumberValue value)
Parameters
value
NumberValueThe value.
Returns
- MassValue
The mass value.
Truncate(MassValue)
Calculates the integral part of a specified value number.
public static MassValue Truncate(MassValue value)
Parameters
value
MassValueAn value to truncate.
Returns
- MassValue
The integral part of value number.
Operators
operator +(MassValue, MassValue)
Adds two objects of MassValue.
public static MassValue operator +(MassValue left, MassValue right)
Parameters
Returns
- MassValue
An object that is the sum of
left
andright
.
operator ==(MassValue, MassValue)
Determines whether two specified instances of MassValue are equal.
public static bool operator ==(MassValue left, MassValue right)
Parameters
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.
operator >(MassValue, MassValue)
Indicates whether left
parameter is greater than the right
parameter.
public static bool operator >(MassValue left, MassValue right)
Parameters
Returns
- bool
true
if theleft
parameter is greater than theright
parameter; otherwise,false
.
operator >=(MassValue, MassValue)
Indicates whether left
parameter is greater than or equal to the right
parameter.
public static bool operator >=(MassValue left, MassValue right)
Parameters
Returns
- bool
true
if theleft
parameter is greater than or equal to theright
parameter; otherwise,false
.
operator !=(MassValue, MassValue)
Determines whether two specified instances of MassValue are equal.
public static bool operator !=(MassValue left, MassValue right)
Parameters
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.
operator <(MassValue, MassValue)
Indicates whether left
parameter is less than the right
parameter.
public static bool operator <(MassValue left, MassValue right)
Parameters
Returns
- bool
true
if theleft
parameter is less than theright
parameter; otherwise,false
.
operator <=(MassValue, MassValue)
Indicates whether left
parameter is less than or equal to the right
parameter.
public static bool operator <=(MassValue left, MassValue right)
Parameters
Returns
- bool
true
if theleft
parameter is less than or equal to theright
parameter; otherwise,false
.
operator -(MassValue, MassValue)
Subtracts two objects of MassValue.
public static MassValue operator -(MassValue left, MassValue right)
Parameters
Returns
- MassValue
An object that is the difference of
left
andright
.
operator -(MassValue)
Produces the negative of MassValue.
public static MassValue operator -(MassValue value)
Parameters
value
MassValueThe value.
Returns
- MassValue
The negative of
value
.