[julia-users] Re: Char Array to Integer Array Problem

2015-06-15 Thread Scott Jones
You can also do something like this to get each character as an integer... you'll need to convert each integer to Int64 as Stefan noted when doing the multiplication. julia> z = reinterpret(Int32,collect(numb_strg[1:12])) .- 48 12-element Array{Int32,1}: 8 2 1 6 6 3 7 0 4 8

Re: [julia-users] Re: Char Array to Integer Array Problem

2015-06-15 Thread Stefan Karpinski
The parseint function is not vectorized – you need to apply parseint to each character using map or a comprehension. In your case, you might as well just subtract '0' from each character. On Mon, Jun 15, 2015 at 2:22 PM, James Byars wrote: > Thank you for the suggestion. I tried to use parseint

Re: [julia-users] Re: Char Array to Integer Array Problem

2015-06-15 Thread Stefan Karpinski
This happens because the character '0' is encoded in ASCII (or UTF-8) as the byte value 48 – i.e. the Uint8 vale 0x30 – and the other digits are the following ASCII byte values, 48-57. If you know that your string is pure ASCII and th

[julia-users] Re: Char Array to Integer Array Problem

2015-06-15 Thread James Byars
Thank you for the suggestion. I tried to use parseint on the Char array and got the following error: `parseint` has no method matching parseint(::Array{Char,1}) On Monday, June 15, 2015 at 1:02:21 PM UTC-4, Huda Nassar wrote: > > You can use the parseint function: > > *julia> **a = '3'* > > *'3

[julia-users] Re: Char Array to Integer Array Problem

2015-06-15 Thread Huda Nassar
You can use the parseint function: *julia> **a = '3'* *'3'* *julia> **typeof(a)* *Char* *julia> **b = parseint(a)* *3* *julia> **typeof(b)* *Int64* On Monday, June 15, 2015 at 12:39:14 PM UTC-4, James Byars wrote: > > Hey all, > > I am working through some Project Euler problem (#008) ab