NumEx v0.1.0 Fraction View Source
A module to perform various operations on Fractions.
Link to this section Summary
Functions
Returns the sum of two Fractions
Returns the quotient of two Fractions
Returns the GCD(greatest common divisor) of two Fractions
Returns the LCM(least common multiple) of two Fractions
Returns the decimal value of a given fraction
Returns the product of two Fractions
Gives a fration structure to the given value
Gives a fration structure to a value
Returns the reciprocal of a Fraction
Returns the difference of two Fractions
Converts a mixed fraction to an improper fraction
Converts an improper fraction to a mixed fraction
Link to this section Functions
Returns the sum of two Fractions
Examples
iex> Fraction.add([2,3],[1,2])
%Fraction{denominator: 6, numerator: 7}
Returns the quotient of two Fractions
Examples
iex> Fraction.fdiv([1,2], [3,4])
%Fraction{denominator: 6, numerator: 4}
Returns the GCD(greatest common divisor) of two Fractions
Examples
iex> Fraction.fgcd([3,4], [1,2])
%Fraction{denominator: 4, numerator: 1}
Returns the LCM(least common multiple) of two Fractions
Examples
iex> Fraction.flcm([3,4], [1,2])
%Fraction{denominator: 2, numerator: 3}
Returns the product of two Fractions
Examples
iex> Fraction.mul([1,2], [3,4])
%Fraction{denominator: 8, numerator: 3}
Gives a fration structure to the given value.
Examples
iex> Fraction.new(15)
%Fraction{denominator: 1, numerator: 15}
iex> Fraction.new(-3)
%Fraction{denominator: 1, numerator: -3}
Gives a fration structure to a value.
Examples
iex> Fraction.new(15, 7)
%Fraction{denominator: 7, numerator: 15}
iex> Fraction.new(-3, 4)
%Fraction{denominator: 4, numerator: -3}
Returns the reciprocal of a Fraction
Examples
iex> Fraction.reciprocal([3,4])
%Fraction{denominator: 3, numerator: 4}
Returns the difference of two Fractions
Examples
iex> Fraction.sub([2,3],[1,2])
%Fraction{denominator: 6, numerator: 1}
Converts a mixed fraction to an improper fraction
Examples
iex> Fraction.to_improper(5, 1, 2)
%Fraction{denominator: 2, numerator: 11}