operate

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

*

  • 四则混合运算类
  • *初始化的时候需要传入公式:
  • *只支持加减乘除和括号 *
  • *execute计算结算方法
  • *参数一个变量和数值的字符串数组
  • *AVAILABLE_PARAMETER_CODE(变量定义,只支持单字节变量)
  • *例:公式a+b*4
  • *参数String[]{"a","1","b","2"}
  • *计算结果9 *

Index

Constants

View Source
const (
	//四则运算符号
	AVAILABLE_CODE = "+-*/()^√"
	//小数符号
	AVAILABLE_DECIMAL_CODE = "1234567890.E"
	//参数符配置
	AVAILABLE_PARAMETER_CODE = "abcdefhijklmn"
)

Variables

View Source
var RecoverPanicToErr = true

Functions

func M2float64

func M2float64(i interface{}) float64

func M2int64

func M2int64(i interface{}) int64

func M2string

func M2string(i interface{}) string

func PanicToErr

func PanicToErr(err *error)

func PanicValToErr

func PanicValToErr(panicVal interface{}, err *error)

func Stof64

func Stof64(v string, def ...float64) float64

没找到并且没有默认值则 panic抛错

func Stoi64

func Stoi64(v string, def ...int64) int64

没找到并且没有默认值则 panic抛错

Types

type Operate

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

* 四则运算类

func NewOperate

func NewOperate(sentence string) (o *Operate, err error)

func (*Operate) Execute

func (this *Operate) Execute(str []string) (value float64, err error)

计算后缀表达式的值

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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