-
-
Save nicanaca0/9efb42097614fcf0d3b00a3e1d9358a5 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains 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
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