Thanks, though a bit convoluted. I think these type of operations are common enough to deserve their own functions in Base.
quinta-feira, 22 de Janeiro de 2015 às 23:36:42 UTC, Seth escreveu: > > > > On Thursday, January 22, 2015 at 3:35:21 PM UTC-8, Seth wrote: >> >> >> >> On Thursday, January 22, 2015 at 3:27:59 PM UTC-8, J Luis wrote: >>> >>> I crossed this behavior when converting a C code that used atoi() and >>> atof() >>> >>> julia> a="12" >>> "12" >>> >>> This is fine, we get the number >>> >>> julia> float(a) >>> 12.0 >>> >>> but now, surprise, we get the ASCII code >>> >>> julia> float(a[2]) >>> 50.0 >>> >> >> This is because a[2] returns Char, which is then evaluated as int 50, as >> you observed. To get the presumably desired behavior (2.0), >> >> float(string(a[2])) >> >> should work. >> >> > > I forgot to add: float(a[2:2]) will also work, as a range subscript > produces a string. >