1.

Solve : Celsius to Farenheit converter?

Answer»

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.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 )you can do simple arithmetic in batch
see here for exampleActually, 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.

How the heck are ya Sidewinder ? ?

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. 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 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).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


Discussion

No Comment Found