Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parseint Int128 edge cases #10498

Closed
tanmaykm opened this issue Mar 13, 2015 · 0 comments
Closed

parseint Int128 edge cases #10498

tanmaykm opened this issue Mar 13, 2015 · 0 comments

Comments

@tanmaykm
Copy link
Member

julia> s = "$(typemax(Int128))0"
"1701411834604692317316873037158841057270"

julia> parseint(Int128, s)
-10

julia> s = "$(typemin(Int128))0"
"-1701411834604692317316873037158841057280"

julia> parseint(Int128, s)
0

julia> s = "170141183460469231731687303715884105728"
"170141183460469231731687303715884105728"

julia> parseint(Int128, s)
-170141183460469231731687303715884105728

Seems to be due to https://github.com/JuliaLang/julia/blob/master/base/string.jl#L1530

tanmaykm added a commit to tanmaykm/julia that referenced this issue Mar 17, 2015
Introduces the tryparse method:
- tryparse{T<:Integer}(::Type{T<:Integer},s::AbstractString)
- tryparse(::Type{Float..},s::AbstractString)
- a few variants of the above

And:
- tryparse(Float.., ...) call the corresponding C functions jl_try_strtof, jl_try_substrtof, jl_try_strtod and jl_try_substrtod.
- The parseint, parsefloat, float64_isvalid and float32_isvalid methods wrap the corresponding tryparse methods.
- The jl_strtod, jl_strtof, ... functions are wrappers over the jl_try_str... functions.

This should fix JuliaLang#10498 as well.

Ref: discussions at JuliaLang#9316, JuliaLang#3631, JuliaLang#5704
tanmaykm added a commit to tanmaykm/julia that referenced this issue Mar 17, 2015
Introduces the tryparse method:
- tryparse{T<:Integer}(::Type{T<:Integer},s::AbstractString)
- tryparse(::Type{Float..},s::AbstractString)
- a few variants of the above

And:
- tryparse(Float.., ...) call the corresponding C functions jl_try_strtof, jl_try_substrtof, jl_try_strtod and jl_try_substrtod.
- The parseint, parsefloat, float64_isvalid and float32_isvalid methods wrap the corresponding tryparse methods.
- The jl_strtod, jl_strtof, ... functions are wrappers over the jl_try_str... functions.

This should fix JuliaLang#10498 as well.

Ref: discussions at JuliaLang#9316, JuliaLang#3631, JuliaLang#5704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant