Skip to content

Instantly share code, notes, and snippets.

@flaviocopes
Last active July 16, 2017 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flaviocopes/f5ad0e50aa0012dedc7b952c69f34530 to your computer and use it in GitHub Desktop.
Save flaviocopes/f5ad0e50aa0012dedc7b952c69f34530 to your computer and use it in GitHub Desktop.
Go: converting temperatures without type aliases (version with type aliases in https://gist.github.com/flaviocopes/2b1f45c510a0e90d703c0aeabe3b0492)
package tempconv
const (
AbsoluteZeroC float64 = -273.15
FreezingC float64 = 0
BoilingC float64 = 100
)
func CToF(c float64) float64 { return float64(c*9/5 + 32) }
func FToC(f float64) float64 { return float64((f - 32) * 5 / 9) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment