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
value
NumberValueThe value.
unit
PowerUnitThe 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
value
PowerValueThe 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
value
PowerValueThe 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
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(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
other
PowerValueAn 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(PowerValue)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(PowerValue other)
Parameters
other
PowerValueAn 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
value
PowerValueThe 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
value
PowerValueThe power value number.
Returns
- PowerValue
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.
Horsepower(double)
Creates the PowerValue struct with Gradian
unit.
public static PowerValue Horsepower(double value)
Parameters
value
doubleThe value.
Returns
- PowerValue
The power value.
Horsepower(NumberValue)
Creates the PowerValue struct with Gradian
unit.
public static PowerValue Horsepower(NumberValue numberValue)
Parameters
numberValue
NumberValueThe value.
Returns
- PowerValue
The power value.
Kilowatt(double)
Creates the PowerValue struct with Kilowatt
unit.
public static PowerValue Kilowatt(double value)
Parameters
value
doubleThe value.
Returns
- PowerValue
The power value.
Kilowatt(NumberValue)
Creates the PowerValue struct with Kilowatt
unit.
public static PowerValue Kilowatt(NumberValue numberValue)
Parameters
numberValue
NumberValueThe 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
powerValue
PowerValueThe power number.
digits
NumberValueThe number of fractional digits in the return value.
Returns
- PowerValue
The number nearest to
powerValue
that has a number of fractional digits equal todigits
. If value has fewer fractional digits thandigits
,powerValue
is returned unchanged.
To(PowerUnit)
Convert to the newUnit
unit.
public PowerValue To(PowerUnit newUnit)
Parameters
newUnit
PowerUnitThe 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
value
PowerValueAn 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
value
doubleThe value.
Returns
- PowerValue
The power value.
Watt(NumberValue)
Creates the PowerValue struct with Watt
unit.
public static PowerValue Watt(NumberValue numberValue)
Parameters
numberValue
NumberValueThe value.
Returns
- PowerValue
The power value.
Operators
operator +(PowerValue, PowerValue)
Adds two objects of PowerValue.
public static PowerValue operator +(PowerValue left, PowerValue right)
Parameters
left
PowerValueThe first object to add.
right
PowerValueThe second object to add.
Returns
- PowerValue
An object that is the sum of
left
andright
.
operator ==(PowerValue, PowerValue)
Determines whether two specified instances of PowerValue are equal.
public static bool operator ==(PowerValue left, PowerValue right)
Parameters
left
PowerValueThe first object to compare.
right
PowerValueThe second object to compare.
Returns
- bool
true
ifleft
is 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
left
PowerValueThe left power value.
right
PowerValueThe right power value.
Returns
- bool
true
if theleft
parameter is greater than theright
parameter; 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
left
PowerValueThe left power value.
right
PowerValueThe right power value.
Returns
- bool
true
if theleft
parameter is greater than or equal to theright
parameter; otherwise,false
.
operator !=(PowerValue, PowerValue)
Determines whether two specified instances of PowerValue are not equal.
public static bool operator !=(PowerValue left, PowerValue right)
Parameters
left
PowerValueThe first object to compare.
right
PowerValueThe second object to compare.
Returns
- bool
true
ifleft
is 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
left
PowerValueThe left power value.
right
PowerValueThe right power value.
Returns
- bool
true
if theleft
parameter is less than theright
parameter; 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
left
PowerValueThe left power value.
right
PowerValueThe right power value.
Returns
- bool
true
if theleft
parameter is less than or equal to theright
parameter; otherwise,false
.
operator -(PowerValue, PowerValue)
Subtracts two objects of PowerValue.
public static PowerValue operator -(PowerValue left, PowerValue right)
Parameters
left
PowerValueThe first object to sub.
right
PowerValueThe second object to sub.
Returns
- PowerValue
An object that is the difference of
left
andright
.
operator -(PowerValue)
Produces the negative of PowerValue.
public static PowerValue operator -(PowerValue value)
Parameters
value
PowerValueThe power value.
Returns
- PowerValue
The negative of
value
.