Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Celsius to Farenheit converter  (Read 7727 times)

0 Members and 1 Guest are viewing this topic.

jjbtcp

    Topic Starter


    Beginner
    Celsius to Farenheit converter
    « on: November 09, 2007, 08:45:36 PM »
    I want to make a batch file that can convert Celsius to Farenheit.

    Below is the mathematical notation needed to make the conversion.
    Celsius * 1.8 + 32

    I made a program that does this in C++ but can't figure out how to make one in batch.


    Thanks.
    Regards,
                     Joshua

    Zylstra

    • Moderator


    • Hacker

    • The Techinator!
    • Thanked: 45
      • Yes
      • Technology News and Information
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 7
    Re: Celsius to Farenheit converter
    « Reply #1 on: November 09, 2007, 09:14:35 PM »
    I dont think this is at all possible in Batch, as Batch is simply for automating lists of tasks. Your better off using a C program, or Qbasic.

    ( Cool tool: http://www.wbuf.noaa.gov/tempfc.htm )

    ghostdog74



      Specialist

      Thanked: 27
      Re: Celsius to Farenheit converter
      « Reply #2 on: November 09, 2007, 09:31:26 PM »
      you can do simple arithmetic in batch
      see here for example

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Celsius to Farenheit converter
      « Reply #3 on: November 10, 2007, 06:42:57 AM »
      Actually, batch code can do simple integer arithmetic. If you use a conversion formula as F = C*9/5+32, you can produce a reasonable approximation.

      Code: [Select]
      C=78

      set /a f=78*9/5+32

      F = 172

      The batch answer is off by .4 --- a decimal value the batch code can't process.

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      patio

      • Moderator


      • Genius
      • Maud' Dib
      • Thanked: 1769
        • Yes
      • Experience: Beginner
      • OS: Windows 7
      Re: Celsius to Farenheit converter
      « Reply #4 on: November 10, 2007, 02:26:03 PM »
      How the heck are ya Sidewinder ? ?

       :)
      " Anyone who goes to a psychiatrist should have his head examined. "

      jjbtcp

        Topic Starter


        Beginner
        Re: Celsius to Farenheit converter
        « Reply #5 on: November 10, 2007, 03:25:29 PM »
        I guess I'll have to teach my friend C++. I want to help him learn but after you teach someone the basics it's hard to go too much further.
        Regards,
                         Joshua

        Zylstra

        • Moderator


        • Hacker

        • The Techinator!
        • Thanked: 45
          • Yes
          • Technology News and Information
        • Certifications: List
        • Computer: Specs
        • Experience: Guru
        • OS: Windows 7
        Re: Celsius to Farenheit converter
        « Reply #6 on: November 10, 2007, 06:56:02 PM »
        Through what I have read about Batch, I never learned once that it could be used for mathematical calculations.
        I apologize for my incorrect advice, I had absolutely no idea

        jjbtcp

          Topic Starter


          Beginner
          Re: Celsius to Farenheit converter
          « Reply #7 on: November 10, 2007, 09:02:09 PM »
          Don't worry, even though your Information was Incorrect, it still holds relevance - when you said:
          Quote
          Your better off using a C program, or Q basic.


          Thanks guys, But all in all I will just have to forget about making one in Batch.

          Sidewinder, Thanks for the code, I know it's only a little bit off but I want it to be precise, Thanks anyway (still might come in useful).
          Regards,
                           Joshua

          yperron



            Rookie
            Re: Celsius to Farenheit converter
            « Reply #8 on: November 13, 2007, 09:27:44 AM »
            you just have to mutliply your values by 100 then add the . at the right place

            Code: [Select]
            @echo off
            set C=78
            echo C  = %C%

            set /a result=%c%*100*9/5+32*100
            set /a f1=%result%/100
            set /a f2=%result%-%f1%*100

            set F=%f1%.%f2%
            echo F  = %F%

            the output is accurate:
            Code: [Select]
            C  = 78
            F  = 172.40

            yp
            yp