fraction_arithmetic: Basic Arithmetic with Fractions

Description Usage Arguments Examples

Description

Functions for doing basic arithmetic with fractions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
add_fractions(x1, x2)

subtract_fractions(x1, x2)

multiply_fractions(x1, x2)

divide_fractions(x1, x2)

x1 %f+% x2

x1 %f-% x2

x1 %f*% x2

x1 %f/% x2

Arguments

x1

The first fraction to be used.

x2

The second fraction to be used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Use as a function
add_fractions("1/2", "1/4")

# Use with the defined infix operator
"1/8" %f+% "2/3"

"1/2" %f/% "1/2"

# Infix operators can be chained
# Operations go from left to right
"-2" %f-% "1/2" %f+% "2 1/3"

# Use parentheses to control order of operations
"-2" %f-% "1/2" %f+% "2 1/3" %f*% "2"

"-2" %f-% "1/2" %f+% ("2 1/3" %f*% "2")

mrdwab/mathrrr documentation built on July 20, 2020, 11:14 p.m.