Table of Contents

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 NumberValue

The value.

unit PowerUnit

The 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

double

Unit

Gets a unit.

public PowerUnit Unit { get; }

Property Value

PowerUnit

Value

Gets a value.

public NumberValue Value { get; }

Property Value

NumberValue

Methods

Abs(PowerValue)

Returns the absolute value of a specified power value.

public static PowerValue Abs(PowerValue value)

Parameters

value PowerValue

The power value.

Returns

PowerValue

The power value, x, that such that 0 ≤ xMaxValue.

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 PowerValue

The 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 object

An 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 PowerValue

An 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 object

The 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 PowerValue

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

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 PowerValue

The 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 PowerValue

The 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 double

The value.

Returns

PowerValue

The power value.

Horsepower(NumberValue)

Creates the PowerValue struct with Gradian unit.

public static PowerValue Horsepower(NumberValue numberValue)

Parameters

numberValue NumberValue

The value.

Returns

PowerValue

The power value.

Kilowatt(double)

Creates the PowerValue struct with Kilowatt unit.

public static PowerValue Kilowatt(double value)

Parameters

value double

The value.

Returns

PowerValue

The power value.

Kilowatt(NumberValue)

Creates the PowerValue struct with Kilowatt unit.

public static PowerValue Kilowatt(NumberValue numberValue)

Parameters

numberValue NumberValue

The 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 PowerValue

The power number.

digits NumberValue

The number of fractional digits in the return value.

Returns

PowerValue

The number nearest to powerValue that has a number of fractional digits equal to digits. If value has fewer fractional digits than digits, powerValue is returned unchanged.

To(PowerUnit)

Convert to the newUnit unit.

public PowerValue To(PowerUnit newUnit)

Parameters

newUnit PowerUnit

The 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 PowerValue

An 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 double

The value.

Returns

PowerValue

The power value.

Watt(NumberValue)

Creates the PowerValue struct with Watt unit.

public static PowerValue Watt(NumberValue numberValue)

Parameters

numberValue NumberValue

The 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 PowerValue

The first object to add.

right PowerValue

The second object to add.

Returns

PowerValue

An object that is the sum of left and right.

operator ==(PowerValue, PowerValue)

Determines whether two specified instances of PowerValue are equal.

public static bool operator ==(PowerValue left, PowerValue right)

Parameters

left PowerValue

The first object to compare.

right PowerValue

The second object to compare.

Returns

bool

true if left is equal to right; 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 PowerValue

The left power value.

right PowerValue

The right power value.

Returns

bool

true if the left parameter is greater than the right 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 PowerValue

The left power value.

right PowerValue

The right power value.

Returns

bool

true if the left parameter is greater than or equal to the right 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 PowerValue

The first object to compare.

right PowerValue

The second object to compare.

Returns

bool

true if left is not equal to right; 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 PowerValue

The left power value.

right PowerValue

The right power value.

Returns

bool

true if the left parameter is less than the right 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 PowerValue

The left power value.

right PowerValue

The right power value.

Returns

bool

true if the left parameter is less than or equal to the right parameter; otherwise, false.

operator -(PowerValue, PowerValue)

Subtracts two objects of PowerValue.

public static PowerValue operator -(PowerValue left, PowerValue right)

Parameters

left PowerValue

The first object to sub.

right PowerValue

The second object to sub.

Returns

PowerValue

An object that is the difference of left and right.

operator -(PowerValue)

Produces the negative of PowerValue.

public static PowerValue operator -(PowerValue value)

Parameters

value PowerValue

The power value.

Returns

PowerValue

The negative of value.