That approach works, at least for 64 bits CPUs.

In v0.2, parse(str) will choke on number overflow and throw a ParseError.

It would be nice if someone using v0.2.1 and a 32bit machine (old OS X?) 
could tell me what happens when you run this:

parse("9223372036854775807")
parse("-9223372036854775808")

—Pierre-Yves

On Friday, February 28, 2014 11:53:51 AM UTC+1, Pierre-Yves Gérardy wrote:
>
> Short of re-implementing parseint, is there a way to work around this?
>
> I was thinking of something like this (for Int64 only)
>
> try
>     num = parseint(Int64, str)
>     if num != parse(str) throw(FOO) end
>     num
> catch ... end
>
> But I don't know if it would work properly on 32 bits CPUs.
>
> -- Pierre-Yves
>
> On Saturday, November 23, 2013 5:07:47 PM UTC+1, Stefan Karpinski wrote:
>>
>> This is now done except for 128-bit integers, where LLVM's overflow 
>> detection is broken on some platforms. Issue opened to track the 128-bit 
>> problems: https://github.com/JuliaLang/julia/issues/4905.
>>
>>
>> On Thu, Nov 21, 2013 at 2:29 AM, Eric Davies <[email protected]> wrote:
>>
>>> Thanks, glad to see this being worked on :)
>>>
>>>
>>> On Wednesday, 20 November 2013 18:15:17 UTC-6, Stefan Karpinski wrote:
>>>
>>>> I started some work on this: https://github.com/JuliaLang/
>>>> julia/pull/4875.
>>>>
>>>>
>>>> On Wed, Nov 20, 2013 at 6:33 PM, Stefan Karpinski <[email protected]
>>>> > wrote:
>>>>
>>>>> Yes, this should raise an error on overflow:
>>>>>
>>>>> https://github.com/JuliaLang/julia/blob/704b852d54cb9b02f07ea084b102de
>>>>> c8fb2dca2a/base/string.jl#L1472
>>>>>
>>>>> Up-for-grabs issue created: https://github.com/JuliaLang/
>>>>> julia/issues/4874.
>>>>>  
>>>>>
>>>>> On Wed, Nov 20, 2013 at 6:00 PM, Eric Davies <[email protected]> wrote:
>>>>>
>>>>>> julia> integer("9223372036854775807")
>>>>>> 9223372036854775807
>>>>>>
>>>>>> julia> integer("9223372036854775808")
>>>>>> -9223372036854775808
>>>>>>
>>>>>> I'm looking for a function that will error (or return some indication 
>>>>>> of validity) on large integers rather than failing. Does such a thing 
>>>>>> exist? It's my opinion that parseint should do this, even though it 
>>>>>> currently performs the same as above.
>>>>>>
>>>>>
>>>>>
>>>>
>>

Reply via email to