IF ISNUMBER ... ?

May 20, 2008
12,375
137
Syracuse, NY, USA
Is there a simple way to determine if a string will represent a number when passed to @EVAL? If there is, I missed it. If not, it would be useful
 
There's @ISFLOAT. But if a string is not a number, @EVAL may interpret it as the name of an environment variable. Which may or may not be defined, which might or might not be a valid number. And then there are other strings like AND and SHR, which are not numbers, and PI, which is.... This is not a trivial question!
 
There's @ISFLOAT. But if a string is not a number, @EVAL may interpret it as the name of an environment variable. Which may or may not be defined, which might or might not be a valid number. And then there are other strings like AND and SHR, which are not numbers, and PI, which is.... This is not a trivial question!
And the likes of log(2) also. I had in mind things that are literally numbers (to @EVAL) ... like the various built-in functions.

And I was really thinking of a unary conditional expression as opposed to a variable function.
 
So you want a function that supports binary, octal, hex, decimal, and float?
I was thinking of anything that @EVAL would take. I don't think octal is in there (is it?) but there is also scientific notation. It's not particularly important to me.
 
At the moment it SEEMS there is no "direct" way to use octal with @EVAL.

A workaround with:

Code:
echo %@eval[%@convert[8,10,17]+%@convert[8,10,12]]
25

works (of course).
 
Last edited: