Skip to content

Commit

Permalink
Fix float64 rounding in the "weather" example (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
destel authored Oct 1, 2024
1 parent 3736822 commit afaad2d
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ func getTemperature(city string, date time.Time) (float64, error) {

// Simulate a temperature reading, by retuning a pseudo-random, but deterministic value
temp := 15 - 10*math.Sin(cityHash+float64(date.Unix()))
temp = math.Round(temp*10) / 10 // Round to one decimal place

return temp, nil
}
Expand Down

0 comments on commit afaad2d

Please sign in to comment.