1

Quick question. I've been looking desperately for a way calculate logarithm in a DOS batch data.Please help kindly.

3 Answers3

3

the best way is making executable logarithm file and use it in your batch file, msdos have not any log function.. you can use some source code like this: http://en.literateprograms.org/Logarithm_Function_(Python)

Mehdi Yeganeh
  • 2,019
  • 2
  • 24
  • 42
  • +1: I agree: the logarithm computation could be done in Python, Perl, Awk or some other scripting language that returns the result on standard output. For example, if you have `bc` available (e.g. from Cygwin), you could use `echo l(2) | bc -l` to return log(2). – Simon Apr 03 '13 at 22:28
1

You may use this very simple Batch-JScript hybrid file:

@if (@CodeSection == @Batch) @then

@echo off

rem JSExpr.bat: Evaluate a JScript (aritmethic) expression
rem Antonio Perez Ayala

Cscript //nologo //E:JScript "%~F0" %1
goto :EOF

End of Batch section

@end

// JScript section

WScript.Echo(eval(WScript.Arguments.Unnamed.Item(0)));

For example:

C:>jsexpr Math.log(10)
2.30258509299405

As a matter of fact, you may evaluate any valid JScript arithmetic expression with previous program. For example:

C:>jsexpr Math.E
2.71828182845905

Search for "jscript reference" (math object), for example: http://msdn.microsoft.com/en-us/library/ie/b272f386(v=vs.94).aspx

Antonio

Aacini
  • 65,180
  • 12
  • 72
  • 108
0

There are several free command line calculators for DOS available. For example EVAL. It's well documented.

Or Mathfc24

peterm
  • 91,357
  • 15
  • 148
  • 157