/* NetRexx */ options replace format comments java crossref symbols nobinary numeric digits 20 loop n_ over getTestData() -- could have used n_.datatype('N') directly here... if isNumeric(n_) then msg = 'numeric' else msg = 'not numeric' say ('"'n_'"').right(25)':' msg end n_ return -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- Pointless in NetRexx; the DATATYPE built-in-function is more powerful! method isNumeric(testString) public static returns boolean return testString.datatype('N') -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ method getTestData() private static returns Rexx[] -- Coercing numbers into the Rexx type has the effect of converting them to strings. -- NetRexx will still perform arithmetic on Rexx strings if those strings represent numbers. -- Notice that whitespace between the sign and the number are ignored even when inside a string constant testData = [ Rexx - ' one and a half', 1, 1.5, 1.5e+27, ' 1 ', ' 1.5 ', ' 1.5e+27 ', - '-one and a half', - 1, - 1.5, - 1.5e-27, ' - 1 ', '- 1.5 ', '- 1.5e-27 ', - '+one and a half', + 1, + 1.5, + 1.5e+27, ' + 1 ', '+ 1.5 ', '+ 1.5e+27 ', - 'Math Constants', - Math.PI, Math.E, - -Math.PI, -Math.E, - +Math.PI, +Math.E, - 'Numeric Constants', - Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY - ] return testData