diff options
Diffstat (limited to 'utilities/utilities.go')
| -rw-r--r-- | utilities/utilities.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/utilities/utilities.go b/utilities/utilities.go index 5143da5..01e2cdd 100644 --- a/utilities/utilities.go +++ b/utilities/utilities.go @@ -24,23 +24,34 @@ import ( "strings" "sync/atomic" "time" + + "golang.org/x/exp/constraints" ) +func Iota(low int, high int) (made []int) { + + made = make([]int, high-low) + for counter := low; counter < high; counter++ { + made[counter-low] = counter + } + return +} + func IsInterfaceNil(ifc interface{}) bool { return ifc == nil || (reflect.ValueOf(ifc).Kind() == reflect.Ptr && reflect.ValueOf(ifc).IsNil()) } -func SignedPercentDifference( - current float64, - previous float64, +func SignedPercentDifference[T constraints.Float | constraints.Integer]( + current T, + previous T, ) (difference float64) { //return ((current - previous) / (float64(current+previous) / 2.0)) * float64( //100, // ) - return ((current - previous) / previous) * float64( - 100, - ) + fCurrent := float64(current) + fPrevious := float64(previous) + return ((fCurrent - fPrevious) / fPrevious) * 100.0 } func AbsPercentDifference( |
