Skip to content

Instantly share code, notes, and snippets.

@vyskocilm
Created December 3, 2020 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vyskocilm/729fb1866cde98e935c989e01568838c to your computer and use it in GitHub Desktop.
Save vyskocilm/729fb1866cde98e935c989e01568838c to your computer and use it in GitHub Desktop.
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