Converting strings to numbers

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed, 29 Nov 2006 17:32:37 -0700

NCL users,

I need to convert strings to integers or reals. Type converters
like stringtoint() will do this. However, I need better error
control than that function provides, because I am trying to validate
unknown data.

For example, "12x3" would be misinterpreted as the number 12 because
stringtoint() apparently stops parsing when it reaches a non-digit,
then merrily outputs a number with no problem indication.

Is there any way in NCL, short of parsing every character myself, to
check whether a complete string is a valid number? I need a
true/false result so that my program can take special action, not
just an error message from NCL. The query functions like
isnumeric() check variable type, not string contents.

Thank you for any advice.

--Dave A.
CU/CIRES Climate Diagnostics Center (CDC)
NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
ncl-talk mailing list
Received on Wed Nov 29 2006 - 17:32:37 MST

This archive was generated by hypermail 2.2.0 : Thu Nov 30 2006 - 14:52:19 MST