Created
September 13, 2022 10:03
-
-
Save anandharaj-dotworld/72f5a6888887327d7e7269020847e5c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func kelvinToCelsius(temp uint32, n int) float64 { | |
// wmi return temperature Kelvin * 10, so need to divide the result by 10, | |
// and then minus 273.15 to get °Celsius. | |
t := float64(temp/10) - 273.15 | |
n10 := math.Pow10(n) | |
return math.Trunc((t+0.5/n10)*n10) / n10 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment