Created
June 21, 2016 15:54
-
-
Save rdp/20e6414f01708242c7a44331b07ab9db to your computer and use it in GitHub Desktop.
golang use rational numbers example
This file contains 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 "math/big" | |
import "fmt" | |
import "time" | |
func main() { | |
fmt.Printf("Hello, world.\n") | |
start := time.Now() | |
r := new(big.Rat) | |
for i := 0; i < 10000000; i++ { | |
r.Add(r, big.NewRat(1, 1)) | |
} | |
elapsed := time.Since(start) | |
fmt.Printf(" took %s %d", elapsed, r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment