Determine if a string is numeric: Difference between revisions

Content deleted Content added
Jjuanhdez (talk | contribs)
Determine if a string is numeric en True BASIC
m →‎{{header|REXX}}: added a few more examples, changed comments and glyphs.
Line 3,584: Line 3,584:


=={{header|REXX}}==
=={{header|REXX}}==
<lang rexx>/*REXX program to determine if a string is numeric. */
<lang rexx>/*REXX program determines if a string is numeric, using REXX's rules for numbers. */
yyy=' -123.78' /*or some such.*/
yyy=' -123.78' /*or some such. */


/*strings below are all numeric (REXX).*/
/*strings below are all numeric (REXX).*/
zzz=' -123.78 '
zzz= ' -123.78 '
zzz='-123.78'
zzz= '-123.78'
zzz='2'
zzz= '2'
zzz="2"
zzz= "2"
zzz=2
zzz= 2
zzz='000000000004'
zzz= '000000000004'
zzz='+5'
zzz= '+5'
zzz=' +6 '
zzz= +5
zzz=' + 7 '
zzz= ' +6 '
zzz=' - 8 '
zzz= ' + 7 '
zzz=' - .9 '
zzz= ' - 8 '
zzz='- 19.'
zzz= ' - .9'
zzz='.7'
zzz= '- 19.'
zzz='2e3'
zzz= '.7'
zzz=47e567
zzz= .7
zzz='2e-3'
zzz= '2e3'
zzz='1.2e1'
zzz= 47e567
zzz=' .2E6'
zzz= '2e-3'
zzz=' 2.e5 '
zzz= '1.2e1'
zzz=' +1.2E0002 '
zzz= ' .2E6'
zzz=' +1.2e+002 '
zzz= ' 2.e5 '
zzz=' +0000001.200e+002 '
zzz= ' +1.2E0002 '
zzz=' - 000001.200e+002 '
zzz= ' +1.2e+002 '
zzz=' - 000008.201e-00000000000000002 '
zzz= ' +0000001.200e+002 '
zzz= ' - 000001.200e+002 '
ifx=i
zzz= ' - 000008.201e-00000000000000002 '


/*Note: some REXX interpreters allow use of tab chars as blanks. */
/*Note: some REXX interpreters allow use of tab chars as blanks. */


/*all statements below are equivalent.*/
/*all statements below are equivalent.*/


if \datatype(yyy,'n') then say 'oops, not numeric:' yyy
if \datatype(yyy, 'n') then say 'oops, not numeric:' yyy
if \datatype(yyy,'N') then say 'oops, not numeric:' yyy
if \datatype(yyy, 'N') then say 'oops, not numeric:' yyy
if ¬datatype(yyy,'N') then say 'oops, not numeric:' yyy
if ¬datatype(yyy, 'N') then say 'oops, not numeric:' yyy
if ¬datatype(yyy,'numeric') then say 'oops, not numeric:' yyy
if ¬datatype(yyy, 'numeric') then say 'oops, not numeric:' yyy
if ¬datatype(yyy,'nim.') then say 'oops, not numeric:' yyy
if ¬datatype(yyy, 'nimrod.') then say 'oops, not numeric:' yyy
if datatype(yyy)\=='NUM' then say 'oops, not numeric:' yyy
if datatype(yyy) \== 'NUM' then say 'oops, not numeric:' yyy
if datatype(yyy)/=='NUM' then say 'oops, not numeric:' yyy
if datatype(yyy) /== 'NUM' then say 'oops, not numeric:' yyy
if datatype(yyy)¬=='NUM' then say 'oops, not numeric:' yyy
if datatype(yyy) ¬== 'NUM' then say 'oops, not numeric:' yyy
if datatype(yyy)¬= 'NUM' then say 'oops, not numeric:' yyy
if datatype(yyy) ¬= 'NUM' then say 'oops, not numeric:' yyy


/*note: REXX only looks at the first char for DATATYPE's 2nd arg. */
/*note: REXX only looks at the first char for DATATYPE's 2nd argument.*/


/*note: some REXX interpreters don't support the ¬ (not) character.*/
/*note: some REXX interpreters don't support the ¬ (not) character. */</lang>
/*note: " " " " " the / as negation. */</lang>


=={{header|Ring}}==
=={{header|Ring}}==