Struct Ratio
- Namespace
- UnitsNet
- Assembly
- UnitsNet.Ratio.dll
In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).
public struct Ratio
Constructors
Ratio(double, RatioUnit)
Creates the quantity with the given numeric value and unit.
public Ratio(double value, RatioUnit unit)
Parameters
value
doubleThe numeric value to construct this quantity with.
unit
RatioUnitThe unit representation to construct this quantity with.
Exceptions
- ArgumentException
If value is NaN or Infinity.
Properties
BaseUnit
The base unit of Ratio, which is Second. All conversions go via this value.
public static RatioUnit BaseUnit { get; }
Property Value
DecimalFractions
Gets a double value of this quantity converted into DecimalFraction
public double DecimalFractions { get; }
Property Value
MaxValue
Represents the largest possible value of Ratio.
public static Ratio MaxValue { get; }
Property Value
MinValue
Represents the smallest possible value of Ratio.
public static Ratio MinValue { get; }
Property Value
PartsPerBillion
Gets a double value of this quantity converted into PartPerBillion
public double PartsPerBillion { get; }
Property Value
PartsPerMillion
Gets a double value of this quantity converted into PartPerMillion
public double PartsPerMillion { get; }
Property Value
PartsPerThousand
Gets a double value of this quantity converted into PartPerThousand
public double PartsPerThousand { get; }
Property Value
PartsPerTrillion
Gets a double value of this quantity converted into PartPerTrillion
public double PartsPerTrillion { get; }
Property Value
Percent
public double Percent { get; }
Property Value
Unit
public RatioUnit Unit { get; }
Property Value
Value
The numeric value this quantity was constructed with.
public double Value { get; }
Property Value
Zero
Gets an instance of this quantity with a value of 0 in the base unit Second.
public static Ratio Zero { get; }
Property Value
Methods
As(RatioUnit)
Convert to the unit representation unit
.
public double As(RatioUnit unit)
Parameters
unit
RatioUnit
Returns
- double
Value converted to the specified unit.
From(double, RatioUnit)
public static Ratio From(double value, RatioUnit fromUnit)
Parameters
Returns
- Ratio
Ratio unit value.
FromDecimalFractions(double)
Creates a Ratio from DecimalFraction.
public static Ratio FromDecimalFractions(double decimalfractions)
Parameters
decimalfractions
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromPartsPerBillion(double)
Creates a Ratio from PartPerBillion.
public static Ratio FromPartsPerBillion(double partsperbillion)
Parameters
partsperbillion
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromPartsPerMillion(double)
Creates a Ratio from PartPerMillion.
public static Ratio FromPartsPerMillion(double partspermillion)
Parameters
partspermillion
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromPartsPerThousand(double)
Creates a Ratio from PartPerThousand.
public static Ratio FromPartsPerThousand(double partsperthousand)
Parameters
partsperthousand
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromPartsPerTrillion(double)
Creates a Ratio from PartPerTrillion.
public static Ratio FromPartsPerTrillion(double partspertrillion)
Parameters
partspertrillion
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
FromPercent(double)
public static Ratio FromPercent(double percent)
Parameters
percent
double
Returns
Exceptions
- ArgumentException
If value is NaN or Infinity.
ToUnit(RatioUnit)
Converts this Ratio to another Ratio with the unit representation unit
.
public Ratio ToUnit(RatioUnit unit)
Parameters
unit
RatioUnit
Returns
- Ratio
A Ratio with the specified unit.