Fraction
ReferencesRepresents a fraction.
Constructors
Properties
Magnitude
#Gets the magnitude or integral part of this fraction. If the fraction is negative, the integral part will be more positive than the fraction value.
Methods
GetHashCode
#Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
Overrides: ValueType.GetHashCode
Rationalise
#Find a fraction which well describes this double.
Returns: Best approximate fraction or UNSET if rationalisation is not possible within the given constraints.
RationalMediants
#Re-implementation of Eric Lippert's dedoublifier algorithm at: https://ericlippert.com/2015/12/10/the-dedoublifier-part-four/
Returns: Sequence of rationals that (over time) approximate x.
Reduce
#Reduce this fraction by reducing the numerator and denominator by the greatest common denominator.
Returns: Reduced fraction.
ToString
#Gets the string representation of this fraction.
Returns: String.
Overrides: ValueType.ToString
Operators
| Operation | Result | Description | ||
|---|---|---|---|---|
| Fraction | + | Fraction | Fraction | Add two fractions. The result is not necessarily in reduced form, as that may be a very slow operation. |
| Fraction | / | Fraction | Fraction | Divide two fractions. The result is not necessarily in reduced form, as that may be a very slow operation. |
| Fraction | == | Fraction | bool | Compare two fractions. Equality is defined numerically, not structurally. Undefined fractions are always unequal. |
| Fraction | > | Fraction | bool | Compare two fractions. |
| Fraction | >= | Fraction | bool | Compare two fractions. |
| Fraction | != | Fraction | bool | Compare two fractions. Inequality is defined numerically, not structurally. Undefined fractions are always unequal. |
| Fraction | < | Fraction | bool | Compare two fractions. |
| Fraction | <= | Fraction | bool | Compare two fractions. |
| Fraction | * | Fraction | Fraction | Multiply two fractions. The result is not necessarily in reduced form, as that may be a very slow operation. |
| Fraction | - | Fraction | Fraction | Subtract two fractions. The result is not necessarily in reduced form, as that may be a very slow operation. |