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

use parse for BigFloat/BigInt #10955

Merged
merged 2 commits into from
Apr 28, 2015
Merged

use parse for BigFloat/BigInt #10955

merged 2 commits into from
Apr 28, 2015

Conversation

simonbyrne
Copy link
Contributor

This deprecates BigInt/BigFloat(::AbstractString) methods, in favour of parse (see #10594 and #10599 ).

  • It also defines big_str and bigfloat_str macros (analogous to the bigint_str macro): on that note, would these be better as BigFloat_str and BigInt_str?
  • I changed the default "base" argument in parse(BigFloat,) to 0: this is basically the same as 10, but allows for use of 0x/0b prefixes for hex-float/bit-float (RFC: bit-float literal #9371) formats.

@simonbyrne simonbyrne changed the title use for BigFloat/BigInt use parse for BigFloat/BigInt Apr 23, 2015
@dpsanders
Copy link
Contributor

Nice. Could we also extend the big function so we can write

big("0.1")

?

I am constantly writing this...

@@ -529,3 +529,6 @@ export float32_isvalid, float64_isvalid
@deprecate parseint(T::Type, s, base) parse(T, s, base)

@deprecate linrange linspace

@deprecate BigFloat(s::AbstractString) parse(BigFloat,AbstractString)
@deprecate BigInt(s::AbstractString) parse(BigInt,AbstractString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these be

@deprecate BigFloat(s::AbstractString) parse(BigFloat,s)
@deprecate BigInt(s::AbstractString) parse(BigInt,s)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@simonbyrne
Copy link
Contributor Author

I've made it a string macro, so you can write

big"0.1"

Is that sufficient, or would a function be useful as well?

@simonbyrne
Copy link
Contributor Author

Okay, I've replaced bigint_str with big_str.

[pao: bit_str is thankfully not what you meant...that would have been confusing]

@StefanKarpinski
Copy link
Sponsor Member

LGTM. @JeffBezanson?

JeffBezanson added a commit that referenced this pull request Apr 28, 2015
@JeffBezanson JeffBezanson merged commit 00d983a into master Apr 28, 2015
@tkelman tkelman deleted the sb/big-parse branch April 28, 2015 05:50
simonster added a commit to JuliaIO/HDF5.jl that referenced this pull request May 5, 2015
@mschauer
Copy link
Contributor

mschauer commented May 6, 2015

Small inconsistency: tryparse() allows a base argument, but parse not.

@simonbyrne
Copy link
Contributor Author

Ah, good point: I was just exposing the GMP/MPFR functionality. Our parse & tryparsefunctions for other types don't support different bases either.

@mschauer
Copy link
Contributor

mschauer commented May 6, 2015

For some Int they do,
julia> parse(Int,"1A",16) 26

@simonbyrne
Copy link
Contributor Author

Ah, good point. We should expose this then.

DSLituiev pushed a commit to DSLituiev/JLD.jl that referenced this pull request Oct 19, 2015
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

Successfully merging this pull request may close these issues.

None yet

6 participants