Struct TemperatureValue
- Namespace
- xFunc.Maths.Expressions.Units.TemperatureUnits
- Assembly
- xFunc.Maths.dll
Represents a number with temperature unit.
public readonly struct TemperatureValue : IEquatable<TemperatureValue>, IComparable<TemperatureValue>, IComparable
- Implements
- Inherited Members
Constructors
TemperatureValue(NumberValue, TemperatureUnit)
Initializes a new instance of the TemperatureValue struct.
public TemperatureValue(NumberValue value, TemperatureUnit unit)
Parameters
valueNumberValueThe value.
unitTemperatureUnitThe 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 TemperatureUnit Unit { get; }
Property Value
Value
Gets a value.
public NumberValue Value { get; }
Property Value
Methods
Abs(TemperatureValue)
Returns the absolute value of a specified temperature value.
public static TemperatureValue Abs(TemperatureValue value)
Parameters
valueTemperatureValueThe temperature value.
Returns
- TemperatureValue
The temperature value,
x, that such that 0 ≤x≤MaxValue.
AsExpression()
Converts TemperatureValue to Temperature.
public Temperature AsExpression()
Returns
- Temperature
The temperature number.
Ceiling(TemperatureValue)
Returns the smallest integral value that is greater than or equal to the specified temperature value.
public static TemperatureValue Ceiling(TemperatureValue value)
Parameters
valueTemperatureValueThe temperature value.
Returns
- TemperatureValue
The smallest integral value.
Celsius(double)
Creates the TemperatureValue struct with Celsius unit.
public static TemperatureValue Celsius(double value)
Parameters
valuedoubleThe value.
Returns
- TemperatureValue
The temperature value.
Celsius(NumberValue)
Creates the TemperatureValue struct with Celsius unit.
public static TemperatureValue Celsius(NumberValue numberValue)
Parameters
numberValueNumberValueThe value.
Returns
- TemperatureValue
The temperature 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
objobjectAn 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 objin the sort order.Zero This instance occurs in the same position in the sort order as obj.Greater than zero This instance follows objin the sort order.
Exceptions
- ArgumentException
objis not the same type as this instance.
CompareTo(TemperatureValue)
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(TemperatureValue other)
Parameters
otherTemperatureValueAn 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(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.
Equals(TemperatureValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(TemperatureValue other)
Parameters
otherTemperatureValueAn object to compare with this object.
Returns
Fahrenheit(double)
Creates the TemperatureValue struct with Fahrenheit unit.
public static TemperatureValue Fahrenheit(double value)
Parameters
valuedoubleThe value.
Returns
- TemperatureValue
The temperature value.
Fahrenheit(NumberValue)
Creates the TemperatureValue struct with Fahrenheit unit.
public static TemperatureValue Fahrenheit(NumberValue numberValue)
Parameters
numberValueNumberValueThe value.
Returns
- TemperatureValue
The temperature value.
Floor(TemperatureValue)
Returns the largest integral value less than or equal to the specified temperature value number.
public static TemperatureValue Floor(TemperatureValue value)
Parameters
valueTemperatureValueThe temperature value.
Returns
- TemperatureValue
The largest integral value.
Frac(TemperatureValue)
Returns the fractional part of the temperature value number.
public static TemperatureValue Frac(TemperatureValue value)
Parameters
valueTemperatureValueThe temperature value number.
Returns
- TemperatureValue
The fractional part.
GetHashCode()
Returns the hash code for this instance.
[ExcludeFromCodeCoverage]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Kelvin(double)
Creates the TemperatureValue struct with Kelvin unit.
public static TemperatureValue Kelvin(double value)
Parameters
valuedoubleThe value.
Returns
- TemperatureValue
The temperature value.
Kelvin(NumberValue)
Creates the TemperatureValue struct with Kelvin unit.
public static TemperatureValue Kelvin(NumberValue numberValue)
Parameters
numberValueNumberValueThe value.
Returns
- TemperatureValue
The temperature value.
Round(TemperatureValue, 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 TemperatureValue Round(TemperatureValue temperatureValue, NumberValue digits)
Parameters
temperatureValueTemperatureValueThe temperature number.
digitsNumberValueThe number of fractional digits in the return value.
Returns
- TemperatureValue
The number nearest to
temperatureValuethat has a number of fractional digits equal todigits. If value has fewer fractional digits thandigits,temperatureValueis returned unchanged.
To(TemperatureUnit)
Convert to the newUnit unit.
public TemperatureValue To(TemperatureUnit newUnit)
Parameters
newUnitTemperatureUnitThe new unit.
Returns
- TemperatureValue
The value in the new unit.
ToCelsius()
Converts the current object to celsius.
public TemperatureValue ToCelsius()
Returns
- TemperatureValue
The power value which is converted to celsius.
ToFahrenheit()
Converts the current object to fahrenheit.
public TemperatureValue ToFahrenheit()
Returns
- TemperatureValue
The power value which is converted to fahrenheit.
ToKelvin()
Converts the current object to kelvin.
public TemperatureValue ToKelvin()
Returns
- TemperatureValue
The power value which is converted to kelvin.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Truncate(TemperatureValue)
Calculates the integral part of a specified temperature value number.
public static TemperatureValue Truncate(TemperatureValue value)
Parameters
valueTemperatureValueAn temperature value to truncate.
Returns
- TemperatureValue
The integral part of temperature value number.
Operators
operator +(TemperatureValue, TemperatureValue)
Adds two objects of TemperatureValue.
public static TemperatureValue operator +(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe first object to add.
rightTemperatureValueThe second object to add.
Returns
- TemperatureValue
An object that is the sum of
leftandright.
operator ==(TemperatureValue, TemperatureValue)
Determines whether two specified instances of TemperatureValue are equal.
public static bool operator ==(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe first object to compare.
rightTemperatureValueThe second object to compare.
Returns
- bool
trueifleftis equal toright; otherwise,false.
operator >(TemperatureValue, TemperatureValue)
Indicates whether left parameter is greater than the right parameter.
public static bool operator >(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe left power value.
rightTemperatureValueThe right power value.
Returns
- bool
trueif theleftparameter is greater than therightparameter; otherwise,false.
operator >=(TemperatureValue, TemperatureValue)
Indicates whether left parameter is greater than or equal to the right parameter.
public static bool operator >=(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe left power value.
rightTemperatureValueThe right power value.
Returns
- bool
trueif theleftparameter is greater than or equal to therightparameter; otherwise,false.
operator !=(TemperatureValue, TemperatureValue)
Determines whether two specified instances of TemperatureValue are not equal.
public static bool operator !=(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe first object to compare.
rightTemperatureValueThe second object to compare.
Returns
- bool
trueifleftis not equal toright; otherwise,false.
operator <(TemperatureValue, TemperatureValue)
Indicates whether left parameter is less than the right parameter.
public static bool operator <(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe left power value.
rightTemperatureValueThe right power value.
Returns
- bool
trueif theleftparameter is less than therightparameter; otherwise,false.
operator <=(TemperatureValue, TemperatureValue)
Indicates whether left parameter is less than or equal to the right parameter.
public static bool operator <=(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe left power value.
rightTemperatureValueThe right power value.
Returns
- bool
trueif theleftparameter is less than or equal to therightparameter; otherwise,false.
operator -(TemperatureValue, TemperatureValue)
Subtracts two objects of TemperatureValue.
public static TemperatureValue operator -(TemperatureValue left, TemperatureValue right)
Parameters
leftTemperatureValueThe first object to sub.
rightTemperatureValueThe second object to sub.
Returns
- TemperatureValue
An object that is the difference of
leftandright.
operator -(TemperatureValue)
Produces the negative of TemperatureValue.
public static TemperatureValue operator -(TemperatureValue value)
Parameters
valueTemperatureValueThe power value.
Returns
- TemperatureValue
The negative of
value.