IF ISNUMBER ... ?

May 20, 2008
11,853
121
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
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,584
97
Albuquerque, NM
prospero.unm.edu
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!
 
May 20, 2008
11,853
121
Syracuse, NY, USA
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.
 
May 20, 2008
11,853
121
Syracuse, NY, USA
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.
 
Jan 12, 2014
481
8
Switzerland, SO
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: