test dw distances
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package number
|
||||
|
||||
import "math"
|
||||
|
||||
func Fixed3(num float64) float64 {
|
||||
return fixed(num, 3)
|
||||
}
|
||||
|
||||
func fixed(num float64, precision int) float64 {
|
||||
output := math.Pow(10, float64(precision))
|
||||
return float64(round(num*output)) / output
|
||||
}
|
||||
|
||||
func round(num float64) int {
|
||||
return int(num + math.Copysign(0.5, num))
|
||||
}
|
||||
Reference in New Issue
Block a user