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. #1
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949

    Fahrenheit...

    ...to celsius. What is the formula for conversion from F to C and C to F? Thanks all !
    Do not make direct eye contact with me.

  2. #2

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    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?

  4. #4
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    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?
    http://www.gi.alaska.edu/ScienceForum/ASF13/1317.html

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

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  5. #5
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    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 .
    Last edited by Lurker; 09-13-2003 at 11:55 PM.
    Do not make direct eye contact with me.

  6. #6
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    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;
    }
    Last edited by Lurker; 09-14-2003 at 12:01 AM.
    Do not make direct eye contact with me.

  7. #7
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Originally posted by Thantos
    What the hell is Fahrenheit based off of?
    It's got something to do with cooking Spaghetti-o's, IIRC.

  8. #8
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    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.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  9. #9
    Senior Member joshdick's Avatar
    Join Date
    Nov 2002
    Location
    Phildelphia, PA
    Posts
    1,146
    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.
    FAQ

    "The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.

    "If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.

  10. #10
    The Defective GRAPE Lurker's Avatar
    Join Date
    Feb 2003
    Posts
    949
    Duhduhduh....thanks man, thats what I needed .
    Do not make direct eye contact with me.

  11. #11
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    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).
    Such is life.

  12. #12
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    >>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.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need the best solution
    By ginom71 in forum C Programming
    Replies: 11
    Last Post: 07-03-2009, 02:51 PM
  2. Conversion from Fahrenheit to Celsius problem
    By -Syntax in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2008, 07:56 PM
  3. Pass by reference
    By mcgeady in forum C Programming
    Replies: 11
    Last Post: 02-17-2005, 02:01 AM
  4. celsius to fahrenheit conversion
    By chipster18 in forum C Programming
    Replies: 11
    Last Post: 03-26-2003, 06:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21