Fraction

Description

struct Tinman.Core.Math.Fraction

Derived from

IEquatable<Fraction>

This struct represents a fraction with a 32-bit integer numerator and denominator.

Public / Constants

Epsilon


public static readonly attribute Epsilon → (Fraction)

The smallest positive fraction value.

Max


public static readonly attribute Max → (Fraction)

The fraction equal to Maths.MaxInt.

Min


public static readonly attribute Min → (Fraction)

The fraction equal to Maths.MinInt.

Neg​Inf


public static readonly attribute NegInf → (Fraction)

The fraction that represents negative infinity.

See also

Maths.NegInfD

One


public static readonly attribute One → (Fraction)

The fraction 1 / 1.

One​Half


public static readonly attribute OneHalf → (Fraction)

The fraction 1 / 2.

One​Percent


public static readonly attribute OnePercent → (Fraction)

The fraction 1 / 100.

One​Quarter


public static readonly attribute OneQuarter → (Fraction)

The fraction 1 / 4.

Pos​Inf


public static readonly attribute PosInf → (Fraction)

The fraction that represents positive infinity.

See also

Maths.PosInfD

Undefined


public static readonly attribute Undefined → (Fraction)

The undefined fraction.

Zero


public static readonly attribute Zero → (Fraction)

The fraction 0 / 1.

Public / Constructors

Of


[Pure]
public static method Of → (2)

numerator in : int64

The 64-bit integer numerator.

denominator opt : int64 = 1

The 64-bit integer denominator.

returns → Fraction

The resulting fraction.

Returns a Fraction value that represents the given 64-bit integer fraction.

Percent


[Pure]
public static method Percent → (1)

percent in : int32

The percentage.

returns → Fraction

The fraction value.

Returns a fraction value that represents a numeric percentage: percent / 100.

Percent​Add


[Pure]
public static method PercentAdd → (1)

percent in : int32

The percentage to add.

returns → Fraction

The fraction value.

Returns a fraction value that adds a numeric percentage: (100 + percent) / 100.

Percent​Sub


[Pure]
public static method PercentSub → (1)

percent in : int32

The percentage to add.

returns → Fraction

The fraction value.

Returns a fraction value that subtracts a numeric percentage: (100 - percent) / 100.

Public / Methods

Add

2 overloads


[Pure]
public method Add1 → (2)

numerator in : int32

The numerator of the fraction to add.

denominator opt : int32 = 1

The denominator of the fraction to add.

returns → Fraction

The resulting fraction.

Adds the given value to this fraction.


[Pure]
public method Add2 → (1)

fraction in : Fraction

The fraction to add.

returns → Fraction

The resulting fraction.

Adds the given value to this fraction.

Div

2 overloads


[Pure]
public method Div1 → (2)

numerator in : int32

The numerator of the fraction to divide by.

denominator opt : int32 = 1

The denominator of the fraction to divide by.

returns → Fraction

The resulting fraction.

Divides this fraction by the given value.


[Pure]
public method Div2 → (1)

fraction in : Fraction

The fraction to divide by.

returns → Fraction

The resulting fraction.

Divides this fraction by the given value.

Mul

2 overloads


[Pure]
public method Mul1 → (2)

numerator in : int32

The numerator of the fraction to multiply with.

denominator opt : int32 = 1

The denominator of the fraction to multiply with.

returns → Fraction

The resulting fraction.

Multiplies this fraction with the given value.


[Pure]
public method Mul2 → (1)

fraction in : Fraction

The fraction to multiply with.

returns → Fraction

The resulting fraction.

Multiplies this fraction with the given value.

Neg


[Pure]
public method Neg → ()

returns → Fraction

The resulting fraction.

Negates this fraction.

Reciprocal


[Pure]
public method Reciprocal → ()

returns → Fraction

The resulting fraction.

Returns the reciprocal of this fraction.

Sub

2 overloads


[Pure]
public method Sub1 → (2)

numerator in : int32

The numerator of the fraction to multiply with.

denominator opt : int32 = 1

The denominator of the fraction to multiply with.

returns → Fraction

The resulting fraction.

Subtracts the given value from this fraction.


[Pure]
public method Sub2 → (1)

fraction in : Fraction

The fraction to subtract.

returns → Fraction

The resulting fraction.

Subtracts the given value from this fraction.

To​Number


[Pure]
public method ToNumber → ()

returns → float64

The floating point value.

Converts this fraction into a 64-bit floating point value.

Public / Attributes

Denominator


public readonly attribute Denominator → (int32)

The denominator of the fraction.

Is​Negative


public attribute IsNegative → (get)

value : bool

true if this fraction is negative, false if not.

Is this fraction negative?

Is​One


public attribute IsOne → (get)

value : bool

true if this fraction is equal to one, false if it is not.

Does this fraction have the value 1?

Is​Undefined


public attribute IsUndefined → (get)

value : bool

true if this fraction is undefined,
false if it has a defined value.

Is this fraction undefined?

Is​Zero


public attribute IsZero → (get)

value : bool

true if this fraction is equal to zero, false if it is not.

Does this fraction have the value 0?

Numerator


public readonly attribute Numerator → (int32)

The numerator of the fraction.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<Fraction>)

The serialization helper object for values of Fraction.