Created
December 3, 2020 11:29
-
-
Save vyskocilm/729fb1866cde98e935c989e01568838c to your computer and use it in GitHub Desktop.
Arbitrary precision calculator for Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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