Last active
August 16, 2018 10:44
-
-
Save sbinet/549a233a4d662b759f68871110c4db51 to your computer and use it in GitHub Desktop.
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 ( | |
"fmt" | |
"log" | |
"math" | |
"os" | |
"strconv" | |
) | |
func main() { | |
if len(os.Args) <= 1 { | |
fmt.Println("Not enough arguments") | |
os.Exit(1) | |
} | |
var ( | |
min = +math.MaxFloat64 | |
max = -math.MaxFloat64 | |
) | |
for _, arg := range os.Args[1:] { | |
v, err := strconv.ParseFloat(arg, 64) | |
if err != nil { | |
log.Fatalf("could not convert %q to float64: %v", arg, err) | |
} | |
if v < min { | |
min = v | |
} | |
if v > max { | |
max = v | |
} | |
} | |
fmt.Printf("Min: %v\n", min) | |
fmt.Printf("Max: %v\n", max) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment