|
Answer» Hi. How do I convert a string to a float? More specifically, I want to convert my algebraic operation to a number of some form (floating point, double).
I'm new to this and have been up and down the reference guide and the forum and can't find the answer.
Thanks. You havent been able to fnd the answer, because there isnt one.
Batch files can cope with INTEGERS (only just) and that is that. For what you want, Id suggest a real programming languageYes, you use a script that does floating point.
Quote http://stackoverflow.com/questions/1503888/floating-point-division-in-a-dos-batch WScript.Echo Eval(WScript.Arguments(0)) You can call this external script from your batch file, specify the expression to be evaluated and get the result back. For example:
echo off for /f %%n in ('cscript //nologo eval.vbs "10/3"') do ( set res=%%n ) echo %res%
Of course, you'll get the result as a string, but it's better than nothing anyway, and you can pass the obtained result to the eval script as part of another expression.
You may wish to do you whole project in WSH.
QuoteWindows Script Host - Wikipedia, the FREE encyclopedia The Microsoft Windows Script Host (WSH) is an automation technology for Microsoft Windows operating systems that provides scripting capabilities comparable to … Windows Script Host is distributed and INSTALLED by default on Windows 98 and later versions of Windows. It is also installed if Internet Explorer 5 (or a later version) is installed. Beginning with Windows 2000, the Windows Script Host became AVAILABLE for use ... http://en.wikipedia.org/wiki/Windows_Script_Host
|