-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (50 loc) · 932 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"bufio"
"fmt"
"log"
"math/rand"
"os"
)
// main is used to generate the sample inputs
func main() {
f64, err := os.Create("float64.samples")
if err != nil {
log.Fatal(err)
}
defer f64.Close()
for _, v := range genFloat64() {
f64.WriteString(v)
}
f32, err := os.Create("float32.samples")
if err != nil {
log.Fatal(err)
}
defer f32.Close()
for _, v := range genFloat32() {
f32.WriteString(v)
}
}
func genFloat32() (result []string) {
for i := 0; i < 100; i++ {
result = append(result, fmt.Sprintf("%g\n", rand.Float32()))
}
return
}
func genFloat64() (result []string) {
for i := 0; i < 100; i++ {
result = append(result, fmt.Sprintf("%g\n", rand.Float64()))
}
return
}
func load(file string) (data []string) {
f, err := os.Open(file)
if err != nil {
panic(err)
}
scnnr := bufio.NewScanner(f)
for scnnr.Scan() {
data = append(data, scnnr.Text())
}
return
}