cleanup
This commit is contained in:
parent
a669e8ba51
commit
81527da94b
1 changed files with 3 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue