By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!set aspect=%@eval[%height / %width]
set /a aspect=%height / %width
One way is to use the %@EVAL function:
Code:set aspect=%@eval[%height / %width]
Or you can use SET /A, which works much like in CMD.EXE but without the octal support biting you at odd moments:
Code:set /a aspect=%height / %width
CMD may not, but TCC's SET /A supports floats.
@EVAL just works better.Code:v:\> set /a float=8/3 2.6666666667 v:\> set /a float*=.5 1.3333333334
Code:v:\> echo %@eval[8/3 * .5] 1.3333333333
CMD may not, but TCC's SET /A supports floats.
@EVAL just works better.Code:v:\> set /a float=8/3 2.6666666667 v:\> set /a float*=.5 1.3333333334
Code:v:\> echo %@eval[8/3 * .5] 1.3333333333
CMD may not, but TCC's SET /A supports floats.
@EVAL just works better.Code:v:\> set /a float=8/3 2.6666666667 v:\> set /a float*=.5 1.3333333334
Code:v:\> echo %@eval[8/3 * .5] 1.3333333333
C:\>set /a float=8 / 3 * .5
1.3333333333
C:\>
Thanks. Yeh, I've tried the "set /a" stuff in the command shell, but, it doesn't support floating numbers.
That's about as straightforward as it gets!E.g., to find the cube root of n, use @EVAL[n**(1/3)].
pb4072, @EVAL lets you do some pretty advanced math as well. It supports exponentiation, bit-manipulation operations, logarithms, trigonometric functions, etc., etc. Want to know what pi is out to 15,000 decimal places? It's got that covered. It's really quite a powerful function should you ever need any of those facilities.
If I have any (very minor) gripe about it, it's that it has no particularly straightforward way to compute roots but I figured out how to get it to do those, too. You can do that by raising a number to the power of the reciprocal of the root you're trying to find. E.g., to find the cube root of n, use @EVAL[n**(1/3)].
function SQR=`%@eval[%1 ** 0.5]`
function ROOTn=`%@eval[%1 ** (1/%2)]`
function Root=`%@eval[10**(log10(%1)/%2)]`
echo Square root of 2=%@SQR[2],^ncubed root of 2=%@ROOTn[2,3]^nanother cubed root=%@Root[2,3]
echo %@eval[ 2 * %@sqr[2]]
...says the mathematics professor.That's about as straightforward as it gets!