package main import ( "log" "math" "strconv" ) func FreqMhztoHz(freq string) string { frequency, err := strconv.ParseFloat(freq, 64) if err != nil { log.Println("could not convert frequency string to int", err) } frequency = frequency / 1000 return strconv.FormatFloat(frequency, 'f', 6, 64) } func FreqHztoMhz(freq string) string { frequency, err := strconv.ParseFloat(freq, 64) if err != nil { log.Println("could not convert frequency string to int", err) } frequency = frequency * 1000 return strconv.FormatFloat(frequency, 'f', 6, 64) } func roundFloat(val float64, precision uint) float64 { ratio := math.Pow(10, float64(precision)) return math.Round(val*ratio) / ratio }