Fahrenheit...

This is a discussion on Fahrenheit... within the A Brief History of Cprogramming.com forums, part of the Community Boards category; ...to celsius. What is the formula for conversion from F to C and C to F? Thanks all !...

1. Fahrenheit...

...to celsius. What is the formula for conversion from F to C and C to F? Thanks all !

2. This is what I've always wondered and haven't been able to find a good answer.

The Celsius scale is based off of the freezing and boiling point of water. What the hell is Fahrenheit based off of?

3. Originally posted by Thantos
This is what I've always wondered and haven't been able to find a good answer.

The Celsius scale is based off of the freezing and boiling point of water. What the hell is Fahrenheit based off of?

It's a wonder what a little googling can accomplish.

4. OK, I must be missing somethign real simple here, but what the hell is wrong here:
Code:
```#include <iostream>
using namespace std;

int main() {
int h = 105, l = 95;
cout << h << " " << l << endl;
h = (5 / 9) * (h - 32);
l = (5 / 9) * (l - 32);
cout << h << " " << l;
h = (9 / 5) * (h + 32);
l = (9 / 5) * (l + 32);
cout << h << " " << l;
return 0;
}```
Thanks all .

5. Ah ha! They should be float's huh! I think I solved it...

EDIT: So heres what I got, but it isnt accurate enough. How could I make it more accurate? Thanks all!

Code:
```#include <iostream>
using namespace std;

int main() {
int h = 105, l = 95;
cout << h << " " << l << endl;
h = (5.0f / 9.0f) * (h - 32);
l = (5.0f / 9.0f) * (l - 32);
cout << h << " " << l << endl;
h = (9.0f / 5.0f) * h + 32;
l = (9.0f / 5.0f) * l + 32;
cout << h << " " << l;
return 0;
}```
EDIT 2:
Alright, what you want a float, you put an f after teh integer, what do you put for doubles? This is more accurate, but i dont want a variable for 5 and 9, and this still isnt accurate enough! Thanks all!

Code:
```#include <iostream>
using namespace std;

int main() {
int h = 105, l = 95;
double d = 5, d2 = 9;
cout << h << " " << l << endl;
h = (d / d2) * (h - 32);
l = (d / d2) * (l - 32);
cout << h << " " << l << endl;
h = (d2 / d) * h + 32;
l = (d2 / d) * l + 32;
cout << h << " " << l;
return 0;
}```

6. Originally posted by Thantos
What the hell is Fahrenheit based off of?
It's got something to do with cooking Spaghetti-o's, IIRC.

7. Originally posted by Thantos
What the hell is Fahrenheit based off of?
It was designed so that the average human body temperature would be 100.0... someone just screwed up a bit in the lab.

8. Originally posted by Lurker
EDIT: So heres what I got, but it isnt accurate enough. How could I make it more accurate? Thanks all!

Code:
`	int h = 105, l = 95;`
There's your problem. You're still saving those temperature calculations into integers, thus losing a good deal of accuracy. Just make 'em doubles.

9. Duhduhduh....thanks man, thats what I needed .

10. Originally posted by Thantos
This is what I've always wondered and haven't been able to find a good answer.

The Celsius scale is based off of the freezing and boiling point of water. What the hell is Fahrenheit based off of?
Its based off of the fact that it is the "proper" temperature scale. Well, if you are old(ish).

11. >>Alright, what you want a float, you put an f after teh integer, what do you put for doubles?

You put nothing after a number for it to be a double.