Files
weatherreporter/internal/forecast/thresholds.go

21 lines
507 B
Go
Raw Normal View History

2026-05-29 17:12:20 +00:00
package forecast
func DifferenceAtLeast(previous float64, current float64, threshold float64) bool {
return abs(current-previous) >= threshold
}
func CrossesAtOrAbove(previous float64, current float64, threshold float64) bool {
return previous < threshold && current >= threshold
}
func CrossesBelow(previous float64, current float64, threshold float64) bool {
return previous >= threshold && current < threshold
}
func abs(value float64) float64 {
if value < 0 {
return -value
}
return value
}