go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/matrix/util.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package matrix 9 10 import ( 11 "math" 12 "strconv" 13 ) 14 15 func minInt(values ...int) int { 16 min := math.MaxInt32 17 18 for x := 0; x < len(values); x++ { 19 if values[x] < min { 20 min = values[x] 21 } 22 } 23 return min 24 } 25 26 func maxInt(values ...int) int { 27 max := math.MinInt32 28 29 for x := 0; x < len(values); x++ { 30 if values[x] > max { 31 max = values[x] 32 } 33 } 34 return max 35 } 36 37 func f64s(v float64) string { 38 return strconv.FormatFloat(v, 'f', -1, 64) 39 } 40 41 func roundToEpsilon(value, epsilon float64) float64 { 42 return math.Nextafter(value, value) 43 }