Skip to content

Instantly share code, notes, and snippets.

@vyskocilm
Created Dec 3, 2020
Embed
What would you like to do?
Arbitrary precision calculator for Go
package main
import (
"fmt"
"github.com/cosmos72/gomacro/fast"
)
func RunGomacro(toeval string) float64 {
interp := fast.New()
vals, _ := interp.Eval(toeval)
// for simplicity, only use the first returned value
return vals[0].Float()
}
func main() {
fmt.Println(RunGomacro(".1+.2"))
// go run main.go
// 0.3
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment