This commit is contained in:
Kyle Brown 2022-08-04 17:06:02 -07:00
parent a669e8ba51
commit 81527da94b

View file

@ -1,5 +1,6 @@
import std/strutils
import std/math
import std/sugar
import types
@ -23,15 +24,8 @@ func stripFeature*(line: string): Feature =
func formatMove*(input: float64): string =
## Round to whole number if possible, otherwise, round to 5 places
# TODO This code is disgusting. I don't care if it works, it needs
# fixed. Badly.
## with zeros trimmed
if input == input.round:
return $input.int
let rounded = $input.round(5)
let roundedSplit = rounded.split(".")
let mainNumber = $roundedSplit[0]
var trailing = $roundedSplit[1]
if trailing.len <= 5: return rounded
else:
trailing = trailing[0 .. 4]
return mainNumber & "." & trailing
return input.round(5).formatFloat(ffDecimal, 5).dup(trimZeros)