Skip to content

Commit d013435

Browse files
committed
Merge pull request #76 from lbenet/lbenet/parse_bigfloat
Implements macro for Base.parse(::BigFloat, s::AbstractString) #74
2 parents adb8a88 + 14f4889 commit d013435

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Currently, the `@compat` macro supports the following syntaxes:
7474

7575
* `names(::DataType)` is now renamed to `fieldnames` [#10332](https://github.com/JuliaLang/julia/pull/10332)
7676

77-
* `parseint` and `parsefloat` are now `parse(T, ...)` [#10543](https://github.com/JuliaLang/julia/pull/10543)
77+
* `parseint` and `parsefloat` are now `parse(T, ...)` [#10543](https://github.com/JuliaLang/julia/pull/10543); along the same line `BigFloat(s::String)` is now `parse(BigFloat,s)` [#10955](https://github.com/JuliaLang/julia/pull/10955).
7878

7979
* `convert(::Ptr{T}, x)` is now `Base.unsafe_convert` [#9986](https://github.com/JuliaLang/julia/pull/9986).
8080
Compat provides an unexported `Compat.unsafe_convert` method that is aliased to `Base.convert` on Julia 0.3 and

src/Compat.jl

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ if VERSION < v"0.4.0-dev+3874"
212212
Base.parse{T<:Union(Float32,Float64)}(::Type{T}, s::AbstractString) = parsefloat(T, s)
213213
end
214214

215+
if VERSION < v"0.4.0-dev+4539"
216+
Base.parse(::Type{BigFloat}, s::AbstractString) = BigFloat(s)
217+
end
218+
215219
if VERSION < v"0.4.0-dev+3710"
216220
const unsafe_convert = Base.convert
217221
else

test/runtests.jl

+1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ end
191191
@test parse(Int16, "1101", 2) == convert(Int16, 13)
192192
@test parse(Float64, "222") == 222.0
193193
@test parse(Float32, "1.1") == convert(Float32, 1.1)
194+
@test parse(BigFloat, "1.125") == convert(BigFloat, 1.125)
194195

195196
# Make sure exports from Libc and Libdl are defined
196197
for x in [:strftime,:systemsleep,:getpid,:FILE,:malloc,:MS_SYNC,:munmap,:flush_cstdio,:realloc,:strptime,:Libc,:errno,:msync,:TmStruct,:calloc,:MS_INVALIDATE,:MS_ASYNC,:time,:strerror,:gethostname,:free,:mmap]

0 commit comments

Comments
 (0)