There is quite an informative FAQ entry for this:
<http://www.jsoftware.com/jwiki/Guides/General%20FAQ#Guides.2BAC8-GeneralFAQ.2BAC8-NumbersandCharacterRepresentations.Howtoconvertbetweennumbersandcharacterrepresentationsofnumbers>

From that FAQ:
"Note that the monadic form of "., called "Do", is a general verb for running a 
J phrase represented as a character vector. Because of this you can run into 
problems where your text array contains negative numbers"

For that reason you are better to use the dyadic form of ". called "Numbers" 
for the conversion.
   ". '1 -2 -3'
2
   _999 ". '1 -2 -3'
1 _2 _3

Also:
   ". '1 0.003 3e-3'
|ill-formed number
|       ".'1 0.003 3e-3'
   _999 ". '1 0.003 3e-3'
1 0.003 0.003

The FAQ also suggests that the dyadic form might be faster.

Other resources of interest might be:
http://www.jsoftware.com/jwiki/Interfaces/Text
http://www.jsoftware.com/jwiki/Addons/tables/dsv

> -----Original Message-----
> From: Don Guinn
>    array_of_strings=:'1 3 5 6',:'2 5 4 7'
>    array_of_strings
> 1 3 5 6
> 2 5 4 7
>    numbers=:"."1 array_of_strings
>    numbers
> 1 3 5 6
> 2 5 4 7
>    +/numbers
> 3 8 9 13
> 
> If the number of numbers in each row varies then the results will be
> zero-padded to make the length the same.
> 
> On Sun, Apr 26, 2009 at 5:31 PM, Charles Holder
> <charles_hol...@hotmail.com> wrote:
> >
> > I have read a file of numbers ('01 25 34 ...') into an array of
> strings. How do I convert them to an array of numbers.
> > _________________________________________________________________
> > Windows Live™ SkyDrive™: Get 25 GB of free online storage.
> >
> http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_04200
> 9
> > ---------------------------------------------------------------------
> -
> > For information about J forums see
> http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to