diff --git a/CHANGELOG.md b/CHANGELOG.md index deb0ae3..db99fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [[v0.8.1]](https://github.com/mlange-42/arche-model/compare/v0.8.0...v0.8.1) + +### Other + +* Improved float formatting in CSV output (#64) + ## [[v0.8.0]](https://github.com/mlange-42/arche-model/compare/v0.7.0...0.8.0) ### Features diff --git a/reporter/csv.go b/reporter/csv.go index 77d71b6..ef996fb 100644 --- a/reporter/csv.go +++ b/reporter/csv.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" "github.com/mlange-42/arche-model/observer" @@ -60,7 +61,7 @@ func (s *CSV) Update(w *ecs.World) { s.builder.Reset() fmt.Fprintf(&s.builder, "%d%s", s.step, s.Sep) for i, v := range values { - fmt.Fprintf(&s.builder, "%f", v) + fmt.Fprint(&s.builder, strconv.FormatFloat(v, 'f', -1, 64)) if i < len(values)-1 { fmt.Fprint(&s.builder, s.Sep) } diff --git a/reporter/csv_snaphot.go b/reporter/csv_snaphot.go index a2c0487..6b2622b 100644 --- a/reporter/csv_snaphot.go +++ b/reporter/csv_snaphot.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" "github.com/mlange-42/arche-model/observer" @@ -67,7 +68,7 @@ func (s *SnapshotCSV) Update(w *ecs.World) { s.builder.Reset() for _, row := range values { for i, v := range row { - fmt.Fprintf(&s.builder, "%f", v) + fmt.Fprint(&s.builder, strconv.FormatFloat(v, 'f', -1, 64)) if i < len(row)-1 { fmt.Fprint(&s.builder, s.Sep) }