Created
November 27, 2017 15:46
-
-
Save MarcAstr0/841e36c3879d03f0fead05bf3145e893 to your computer and use it in GitHub Desktop.
Simple library for converting temperatures from Celsius to Fahrenheit and vice versa.
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
#include "temperature.h" | |
#include <math.h> | |
float to_fahrenheit(float celsius) { | |
float fahrenheit; | |
fahrenheit = roundf( ( (celsius * (9.00f/5.00f)) + 32.00f ) * 100.00f ) / 100.00f; | |
return fahrenheit; | |
} | |
float to_celsius(float fahrenheit) { | |
float celsius; | |
celsius = roundf( ( (fahrenheit - 32.00f) * (5.00f/9.00f) ) * 100.00f ) / 100.00f; | |
return celsius; | |
} |
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
#ifndef LIBTEMP_LIBRARY_H | |
#define LIBTEMP_LIBRARY_H | |
float to_fahrenheit(float); | |
float to_celsius(float); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment