Struct PowerValue
- Namespace
 - xFunc.Maths.Expressions.Units.PowerUnits
 
- Assembly
 - xFunc.Maths.dll
 
Represents a number with power unit.
public readonly struct PowerValue : IEquatable<PowerValue>, IComparable<PowerValue>, IComparable
  - Implements
 
- Inherited Members
 
Constructors
PowerValue(NumberValue, PowerUnit)
Initializes a new instance of the PowerValue struct.
public PowerValue(NumberValue value, PowerUnit unit)
  Parameters
valueNumberValueThe value.
unitPowerUnitThe 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 PowerUnit Unit { get; }
  Property Value
Value
Gets a value.
public NumberValue Value { get; }
  Property Value
Methods
Abs(PowerValue)
Returns the absolute value of a specified power value.
public static PowerValue Abs(PowerValue value)
  Parameters
valuePowerValueThe power value.
Returns
- PowerValue
 The power value,
x, that such that 0 ≤x≤MaxValue.
AsExpression()
Converts PowerValue to Power.
public Power AsExpression()
  Returns
- Power
 The power number.
Ceiling(PowerValue)
Returns the smallest integral value that is greater than or equal to the specified power value.
public static PowerValue Ceiling(PowerValue value)
  Parameters
valuePowerValueThe power value.
Returns
- PowerValue
 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
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(PowerValue)
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(PowerValue other)
  Parameters
otherPowerValueAn 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(PowerValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(PowerValue other)
  Parameters
otherPowerValueAn object to compare with this object.
Returns
Floor(PowerValue)
Returns the largest integral value less than or equal to the specified power value number.
public static PowerValue Floor(PowerValue value)
  Parameters
valuePowerValueThe power value.
Returns
- PowerValue
 The largest integral value.
Frac(PowerValue)
Returns the fractional part of the power value number.
public static PowerValue Frac(PowerValue value)
  Parameters
valuePowerValueThe power value number.
Returns
- PowerValue
 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.
Horsepower(double)
Creates the PowerValue struct with Gradian unit.
public static PowerValue Horsepower(double value)
  Parameters
valuedoubleThe value.
Returns
- PowerValue
 The power value.
Horsepower(NumberValue)
Creates the PowerValue struct with Gradian unit.
public static PowerValue Horsepower(NumberValue numberValue)
  Parameters
numberValueNumberValueThe value.
Returns
- PowerValue
 The power value.
Kilowatt(double)
Creates the PowerValue struct with Kilowatt unit.
public static PowerValue Kilowatt(double value)
  Parameters
valuedoubleThe value.
Returns
- PowerValue
 The power value.
Kilowatt(NumberValue)
Creates the PowerValue struct with Kilowatt unit.
public static PowerValue Kilowatt(NumberValue numberValue)
  Parameters
numberValueNumberValueThe value.
Returns
- PowerValue
 The power value.
Round(PowerValue, 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 PowerValue Round(PowerValue powerValue, NumberValue digits)
  Parameters
powerValuePowerValueThe power number.
digitsNumberValueThe number of fractional digits in the return value.
Returns
- PowerValue
 The number nearest to
powerValuethat has a number of fractional digits equal todigits. If value has fewer fractional digits thandigits,powerValueis returned unchanged.
To(PowerUnit)
Convert to the newUnit unit.
public PowerValue To(PowerUnit newUnit)
  Parameters
newUnitPowerUnitThe new unit.
Returns
- PowerValue
 The value in the new unit.
ToHorsepower()
Converts the current object to horsepower.
public PowerValue ToHorsepower()
  Returns
- PowerValue
 The power value which is converted to horsepowers.
ToKilowatt()
Converts the current object to kilowatt.
public PowerValue ToKilowatt()
  Returns
- PowerValue
 The power value which is converted to kilowatts.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
  Returns
- string
 The fully qualified type name.
ToWatt()
Converts the current object to watt.
public PowerValue ToWatt()
  Returns
- PowerValue
 The power value which is converted to watts.
Truncate(PowerValue)
Calculates the integral part of a specified power value number.
public static PowerValue Truncate(PowerValue value)
  Parameters
valuePowerValueAn power value to truncate.
Returns
- PowerValue
 The integral part of power value number.
Watt(double)
Creates the PowerValue struct with Watt unit.
public static PowerValue Watt(double value)
  Parameters
valuedoubleThe value.
Returns
- PowerValue
 The power value.
Watt(NumberValue)
Creates the PowerValue struct with Watt unit.
public static PowerValue Watt(NumberValue numberValue)
  Parameters
numberValueNumberValueThe value.
Returns
- PowerValue
 The power value.
Operators
operator +(PowerValue, PowerValue)
Adds two objects of PowerValue.
public static PowerValue operator +(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe first object to add.
rightPowerValueThe second object to add.
Returns
- PowerValue
 An object that is the sum of
leftandright.
operator ==(PowerValue, PowerValue)
Determines whether two specified instances of PowerValue are equal.
public static bool operator ==(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe first object to compare.
rightPowerValueThe second object to compare.
Returns
- bool
 trueifleftis equal toright; otherwise,false.
operator >(PowerValue, PowerValue)
Indicates whether left parameter is greater than the right parameter.
public static bool operator >(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe left power value.
rightPowerValueThe right power value.
Returns
- bool
 trueif theleftparameter is greater than therightparameter; otherwise,false.
operator >=(PowerValue, PowerValue)
Indicates whether left parameter is greater than or equal to the right parameter.
public static bool operator >=(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe left power value.
rightPowerValueThe right power value.
Returns
- bool
 trueif theleftparameter is greater than or equal to therightparameter; otherwise,false.
operator !=(PowerValue, PowerValue)
Determines whether two specified instances of PowerValue are not equal.
public static bool operator !=(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe first object to compare.
rightPowerValueThe second object to compare.
Returns
- bool
 trueifleftis not equal toright; otherwise,false.
operator <(PowerValue, PowerValue)
Indicates whether left parameter is less than the right parameter.
public static bool operator <(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe left power value.
rightPowerValueThe right power value.
Returns
- bool
 trueif theleftparameter is less than therightparameter; otherwise,false.
operator <=(PowerValue, PowerValue)
Indicates whether left parameter is less than or equal to the right parameter.
public static bool operator <=(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe left power value.
rightPowerValueThe right power value.
Returns
- bool
 trueif theleftparameter is less than or equal to therightparameter; otherwise,false.
operator -(PowerValue, PowerValue)
Subtracts two objects of PowerValue.
public static PowerValue operator -(PowerValue left, PowerValue right)
  Parameters
leftPowerValueThe first object to sub.
rightPowerValueThe second object to sub.
Returns
- PowerValue
 An object that is the difference of
leftandright.
operator -(PowerValue)
Produces the negative of PowerValue.
public static PowerValue operator -(PowerValue value)
  Parameters
valuePowerValueThe power value.
Returns
- PowerValue
 The negative of
value.