rational

package
v0.0.0-...-89013a2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2016 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RationalsAreNull

func RationalsAreNull(l []Rational) (isNull bool)

RationalsAreNull determines whether the slice of Rationals contains only zero values.

Types

type Rational

type Rational struct {
	// contains filtered or unexported fields
}

Rational stores a rational value.

func New

func New(n, d int64) Rational

New returns new rational number representation.

func NewFromFloat

func NewFromFloat(f float64) (ev Rational, err error)

NewFromFloat returns new rational number representation retrieved from float64.

func (Rational) Add

func (ev Rational) Add(e Rational) (nv Rational)

Add adds the provided rational value to an existing one.

func (Rational) AddNum

func (ev Rational) AddNum(i int64) Rational

AddNum adds the provided integer to an existing rational number.

func (Rational) Divide

func (ev Rational) Divide(e Rational) (nv Rational)

Divide divides a rational value by the provided one.

func (Rational) DivideByNum

func (ev Rational) DivideByNum(i int64) Rational

DivideByNum divides a rational value by the provided integer.

func (Rational) Float64

func (ev Rational) Float64() float64

Float64 returns the float64 representation of a rational number.

func (Rational) Get

func (ev Rational) Get() (numerator, denominator int64)

Get returns a value.

func (Rational) GetDenominator

func (ev Rational) GetDenominator() int64

GetDenominator returns a denominator.

func (Rational) GetModule

func (ev Rational) GetModule() Rational

GetModule returns rational number's module.

func (Rational) GetNumerator

func (ev Rational) GetNumerator() int64

GetNumerator returns a numerator.

func (Rational) GreaterThan

func (ev Rational) GreaterThan(e Rational) bool

GreaterThan returns true if a rational is greater than the passed one.

func (Rational) GreaterThanNum

func (ev Rational) GreaterThanNum(i int64) bool

GreaterThanNum returns true if a rational is greater than the passed integer.

func (Rational) IsNatural

func (ev Rational) IsNatural() bool

IsNatural determines whether the rational number is also natural.

func (Rational) IsNull

func (ev Rational) IsNull() (n bool)

IsNull determines whether the value is zero.

func (Rational) LessThan

func (ev Rational) LessThan(e Rational) bool

LessThan returns true if a rational is less than the passed one.

func (Rational) LessThanNum

func (ev Rational) LessThanNum(i int64) bool

LessThanNum returns true if a rational is less than the passed integer.

func (Rational) Multiply

func (ev Rational) Multiply(e Rational) (nv Rational)

Multiply multiplies a rational value by provided one.

func (Rational) MultiplyByNum

func (ev Rational) MultiplyByNum(i int64) Rational

MultiplyByNum multiplies a rational value by the provided integer.

func (*Rational) Simplify

func (ev *Rational) Simplify()

Simplify simplifies the rational number by dividing it's numerator and denominator by the GCD.

func (Rational) Subtract

func (ev Rational) Subtract(e Rational) (nv Rational)

Subtract subtracts the provided rational value from an existing one.

func (Rational) SubtractNum

func (ev Rational) SubtractNum(i int64) Rational

SubtractNum subtracts the provided integer from an existing rational number.

Jump to

Keyboard shortcuts

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