fractions

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 2 Imported by: 0

README

fractions logo
Donate Status


Getting started

Fractions is a Go library that adds fraction-like capabilities to Go. If you want to install Fractions simply run the command shown below in your terminal.

go get github.com/TimoKats/fractions

Next, after installing Fractions you can import (and test) the installation with the code shown below. If this outputs 1 2/3 then the installation has been completed correctly.

package main

import (
	"github.com/TimoKats/fractions"
)

func main() {
	y1 := fractions.FloatToFrac(1.67)
	fractions.PrintFrac(y1)
}

Functionalities

This library saves fractions as objects/structs (called frac) and has functions for: printing, setting, getting, formatting and computing. Hereby a short overview of them all.

print functions

  • PrintFrac(frac *frac)
  • PrintNumerator(frac *frac)
  • PrintDenominator(frac *frac)
  • PrintInteger(frac *frac)

set functions

  • MakeFrac(integer int, numerator int, denominator int)
  • SetNumerator(frac *frac, value int)
  • SetDenominator(frac *frac, value int)
  • SetInteger(frac *frac, value int)

get functions

  • GetNumerator(frac *frac)
  • GetDenominator(frac *frac)
  • GetInteger(frac *frac)

conversion functions

  • FloatToFrac(value float64)
  • FracToFloat(frac *frac)

formatting functions

  • FormatFracOnly(frac *frac)
  • FormatSimplify(frac *frac)

operations

  • SumFrac(frac1 *frac, frac2 *frac)
  • SumInt(frac1 *frac, frac2 *frac)
  • SubtractFrac(frac1 *frac, frac2 *frac)
  • SubtractInt(frac1 *frac, frac2 *frac)
  • SubtractInt(frac1 *frac, value int)
  • DivideFrac(frac1 *frac, frac2 *frac)
  • DivideInt(frac1 *frac, value int)
  • PowerFrac(frac1 *frac, value int)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DivideFrac

func DivideFrac(frac1 *frac, frac2 *frac) *frac

func DivideInt

func DivideInt(frac1 *frac, value int) *frac

func EqualDenominators

func EqualDenominators(frac1 *frac, frac2 *frac) bool

func EqualizeDenominators

func EqualizeDenominators(frac1 *frac, frac2 *frac)

func FloatToFrac

func FloatToFrac(value float64) *frac

func FormatFracOnly

func FormatFracOnly(frac *frac)

func FormatSimplify

func FormatSimplify(frac *frac)

func FracToFloat

func FracToFloat(frac *frac) float64

func GetDenominator

func GetDenominator(frac *frac) int

func GetInteger

func GetInteger(frac *frac) int

func GetNumerator

func GetNumerator(frac *frac) int

func MakeFrac

func MakeFrac(integer int, numerator int, denominator int) *frac

func MultiplyFrac

func MultiplyFrac(frac1 *frac, frac2 *frac) *frac

func MultiplyInt

func MultiplyInt(frac1 *frac, value int) *frac

func PowerFrac

func PowerFrac(frac1 *frac, value int) *frac

func PrintDenominator

func PrintDenominator(frac *frac)

func PrintFrac

func PrintFrac(frac *frac)

func PrintInteger

func PrintInteger(frac *frac)

func PrintNumerator

func PrintNumerator(frac *frac)

func SetDenominator

func SetDenominator(frac *frac, value int)

func SetInteger

func SetInteger(frac *frac, value int)

func SetNumerator

func SetNumerator(frac *frac, value int)

func SubtractFrac

func SubtractFrac(frac1 *frac, frac2 *frac) *frac

func SubtractInt

func SubtractInt(frac1 *frac, value int) *frac

func SumFrac

func SumFrac(frac1 *frac, frac2 *frac) *frac

func SumInt

func SumInt(frac1 *frac, value int) *frac

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL