Table of Contents

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 double

The numeric value to construct this quantity with.

unit RatioUnit

The 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

RatioUnit

DecimalFractions

Gets a double value of this quantity converted into DecimalFraction

public double DecimalFractions { get; }

Property Value

double

MaxValue

Represents the largest possible value of Ratio.

public static Ratio MaxValue { get; }

Property Value

Ratio

MinValue

Represents the smallest possible value of Ratio.

public static Ratio MinValue { get; }

Property Value

Ratio

PartsPerBillion

Gets a double value of this quantity converted into PartPerBillion

public double PartsPerBillion { get; }

Property Value

double

PartsPerMillion

Gets a double value of this quantity converted into PartPerMillion

public double PartsPerMillion { get; }

Property Value

double

PartsPerThousand

Gets a double value of this quantity converted into PartPerThousand

public double PartsPerThousand { get; }

Property Value

double

PartsPerTrillion

Gets a double value of this quantity converted into PartPerTrillion

public double PartsPerTrillion { get; }

Property Value

double

Percent

Gets a double value of this quantity converted into Percent

public double Percent { get; }

Property Value

double

Unit

public RatioUnit Unit { get; }

Property Value

RatioUnit

Value

The numeric value this quantity was constructed with.

public double Value { get; }

Property Value

double

Zero

Gets an instance of this quantity with a value of 0 in the base unit Second.

public static Ratio Zero { get; }

Property Value

Ratio

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)

Dynamically convert from value and unit enum RatioUnit to Ratio.

public static Ratio From(double value, RatioUnit fromUnit)

Parameters

value double

Value to convert from.

fromUnit RatioUnit

Unit to convert from.

Returns

Ratio

Ratio unit value.

FromDecimalFractions(double)

Creates a Ratio from DecimalFraction.

public static Ratio FromDecimalFractions(double decimalfractions)

Parameters

decimalfractions double

Returns

Ratio

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

Ratio

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

Ratio

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

Ratio

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

Ratio

Exceptions

ArgumentException

If value is NaN or Infinity.

FromPercent(double)

Creates a Ratio from Percent.

public static Ratio FromPercent(double percent)

Parameters

percent double

Returns

Ratio

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.