Documentation ¶
Index ¶
- func BigratToBigint(bigrat *big.Rat) *big.Int
- func BigratToFloat(bigrat *big.Rat) float64
- func BigratToInt(bigrat *big.Rat) (int64, error)
- func Eval(expr string) (result *big.Rat, err error)
- func EvalWithVariables(expr string, variables map[string]string) (result *big.Rat, err error)
- func FloatToBigrat(float float64) *big.Rat
- func Tokenise(expr string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BigratToBigint ¶
BigratToInt converts a *big.Rat to a *big.Int (with truncation)
func BigratToFloat ¶
BigratToFloat converts a *big.Rat to a float64 (with loss of precision).
func BigratToInt ¶
BigratToInt converts a *big.Rat to an int64 (with truncation); it returns an error for integer overflows.
func Eval ¶
Eval takes an infix string arithmetic expression, and evaluates it
Usage:
result, err := evaler.Eval("1+2")
Returns: the result of the evaluation, and any errors
func EvalWithVariables ¶
EvalWithVariables allows variables to be passed into expressions, for example evaluate "x + 1" where x=5
func FloatToBigrat ¶
FloatToBigrat converts a float64 to a *big.Rat.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.