Re: Octal conversion with stringtoint

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Tue, 22 Jul 2008 15:28:47 -0600

Hi Dave,

Due to the inconvenience of the requirement to remove leading zeros
when an octal interpretation was not desired, octal conversion was
removed from
the stringto<inttype> functions as of version 4.2.0.a033 (released
January 23, 2006). Apparently the documentation was not updated to
reflect this fact.
In fact, from reviewing the change logs, it seems that octal
conversion was never in a release version of NCL. It was part of the
development version
only from February to December 2005.

It appears that the documentation that claims this capability has
always been in error.
We will correct this oversight as soon as possible.
  -dave

On Jul 17, 2008, at 8:20 PM, Dave Allured wrote:

> NCL support,
>
> There is a problem with the "stringtoint" family of type
> converters. The documentation says that a string of digits with a
> leading zero will be interpreted in octal. However, I seem to be
> getting decimal conversion rather than octal on my system, Mac OS
> 10.5 on PPC, NCL versions 4.2 through 5.0.1 (pre-release).
>
> These functions all act the same way:
>
> stringtoint
> stringtointeger
> stringtoshort
> stringtolong
>
> Please see the attached demo program, which incorporates parts of
> Example 3 on each function's documentation page. For octal
> conversion I am getting the integers 5, 100, 222 instead of the
> expected values 5, 64, 146.
>
> I wonder whether this is widespread on other platforms, and how
> much existing user code is silently depending on the actual
> behavior with decimal data that includes leading zeros. Thanks for
> your consideration.
>
> Dave Allured
> CU/CIRES Climate Diagnostics Center (CDC)
> http://cires.colorado.edu/science/centers/cdc/
> NOAA/ESRL/PSD, Climate Analysis Branch (CAB)
> http://www.cdc.noaa.gov/
> ;---------------------------------------------------------------------
> ;
> ; Test for string conversion functions with octal representation.
> ;
> ; Downloaded 2008-jul-17
> ; From NCL website:
> ; http://www.ncl.ucar.edu/Document/Functions/Built-in/
> stringtoint.shtml
> ;
> ; Modifications:
> ;
> ; 1. Tests for other stringto... functions were added.
> ; 2. Output format was modified for clarity.
> ;
> ;---------------------------------------------------------------------
> -
>
> ; Example 3
> ; Shows how octal and hexadecimal string representations are handled.
>
> begin
>
> ; Specify an array of strings representing octal numbers
>
> a = (/"05", "0100", "0222"/)
>
> print ("")
> print ("Octal conversion, stringtoint, expected = (/ 5, 64, 146 /)")
>
> b = stringtoint(a)
> print(b+"")
>
> ;-----------------------------
>
> ; Specify an array of strings representing hexadecimal numbers
>
> c = (/"0x5", "0x10", "0x9A"/)
>
> print ("")
> print ("Hexadecimal conversion, stringtoint, expected = (/ 5, 16,
> 154 /)")
>
> d = stringtoint(c)
> print(d+"")
>
> ;-----------------------------
>
> print ("")
> print ("Octal conversion, stringtointeger, expected = (/ 5, 64,
> 146 /)")
>
> b2 = stringtointeger(a)
> print(b2+"")
>
> ;-----------------------------
>
> print ("")
> print ("Octal conversion, stringtoshort, expected = (/ 5, 64,
> 146 /)")
>
> b3 = stringtoshort(a)
> print(b3+"")
>
> ;-----------------------------
>
> print ("")
> print ("Octal conversion, stringtolong, expected = (/ 5, 64,
> 146 /)")
>
> b4 = stringtolong(a)
> print(b4+"")
> end
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jul 22 2008 - 15:28:47 MDT

This archive was generated by hypermail 2.2.0 : Fri Jul 25 2008 - 11:11:16 MDT