Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
kelvin_to_celsius.cpp File Reference

Conversion from Kelvin to Celsius degrees. More...

#include <cassert>
#include <cmath>
#include <iostream>
Include dependency graph for kelvin_to_celsius.cpp:

Namespaces

namespace  others
 for vector
 

Functions

bool others::are_almost_equal (double a, double b, double absolute_tolerance=0.0001)
 Compare two floating point numbers with a certain tolerance. This is needed as with some values, the result (e.g.: -196.15) might be a bit lower (in this case, -196.499999...).
 
double others::kelvin_to_celsius (double temperature_in_k)
 Conversion from Kelvin to Celsius algorithm.
 
static void tests ()
 Self-test implementations.
 
int main ()
 Main function.
 

Detailed Description

Conversion from Kelvin to Celsius degrees.

The algorithm consists on converting a Kelvin degree value to a Celsius value. The formula to convert a Kelvin to a Celsius value is:

\[ C = K - 273.15 \]

where:

  • C is the Celsius temperature
  • K is the Kelvin temperature

Check out Kelvin and Celsius on Wikipedia for more information about their story, how do they work, when and why they should be used, etc..

Author
David Leal

Function Documentation

◆ main()

int main ( void )

Main function.

Returns
0 on exit
78 {
79 tests(); // run self-test implementations
80 return 0;
81}
static void tests()
Self-test implementations.
Definition kelvin_to_celsius.cpp:62
Here is the call graph for this function:

◆ tests()

static void tests ( )
static

Self-test implementations.

Returns
void
62 {
70
71 std::cout << "All tests have successfully passed!\n";
72}
double kelvin_to_celsius(double temperature_in_k)
Conversion from Kelvin to Celsius algorithm.
Definition kelvin_to_celsius.cpp:49
bool are_almost_equal(double a, double b, double absolute_tolerance=0.0001)
Compare two floating point numbers with a certain tolerance. This is needed as with some values,...
Definition kelvin_to_celsius.cpp:40
Here is the call graph for this function: