Skip to content

Instantly share code, notes, and snippets.

@nicanaca0
Forked from anonymous/playground.rs
Created May 2, 2017 15:52
Show Gist options
  • Save nicanaca0/9efb42097614fcf0d3b00a3e1d9358a5 to your computer and use it in GitHub Desktop.
Save nicanaca0/9efb42097614fcf0d3b00a3e1d9358a5 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