Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2017 15:51
Show Gist options
  • Save anonymous/23e23db0fb70060b60d3b486e4a21dc4 to your computer and use it in GitHub Desktop.
Save anonymous/23e23db0fb70060b60d3b486e4a21dc4 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
fn to_celcius(value: f64) -> f64 {
(value - 32.0) * (5.0 / 9.0)
}
fn to_fahrenheit(value: f64) -> f64 {
(value * (9.0 / 5.0)) + 32.0
}
fn main() {
println!("{:.1}°C", to_celcius(40.0));
println!("{:.1}°F", to_fahrenheit(40.0));
println!("{:.1}°C", to_celcius(-40.0));
println!("{:.1}°F", to_fahrenheit(-40.0));
println!("Answer: {:.1}°F", to_fahrenheit(45.0));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment