-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Move BigFloat
to stdlib
#25716
Comments
We should definitely move BigFloat to stdlib. |
One possible solution to the |
Yes, that sounds ok. The type piracy here also does not bother me. Initially you have no way to widen a Float64, but if you load the BigFloats package then you do. Makes sense to me. |
As I noted on Discourse, I'm afraid we can't define |
I don't see a ton of advantage to this. We basically need to have BigInt in Base since we have syntax for it (long integer literals). We only export |
other arbitrary precision numbers? (I mean, packages might extend the function with a method for arbfloats, ...) |
Right, so we want a shared extension point anyway, which means to me that |
The main advantage as I see it is that the MPFR dependency could eventually be made optional. |
Agreed, I see this as a step towards making MPFR fully optional. |
Is this still something we can accomplish? Assuming the list that @simonbyrne posted is roughly accurate, it seems quite doable. |
A good first step is to remove from Base and make an stdlib. Can we do both BigFloat and BigInt as stdlibs? That paves the way for eventual separation. |
BigInt and BigFloat share their first three letters, and that is their most alike quality. |
The first step is to figure out how to deal with the fact that e.g. big integers are a part of the syntax of the language:
What should this mean when BigInt is an stdlib and might not be available? Do you need to add a dependency to BigInts if you write big number literals in your code? |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@KristofferC Aren't stdlibs always available? |
Not really, for example, you can filter them out with PackageCompiler if the project file shows that you do not use them. You are also required to declare them as a dependency if you intend to use them to be able to load them in packages. It seems weird that the presence of a standard library can influence what is correct syntax in the language. |
So maybe close this issue then? |
I was only talking about BigInt here. BigFloat should be movable I think. |
Wouldn't it be a bit odd though to have one as a stdlib and not the other, since then you have to know which one needs to be declared as a depencency and which one is not? |
One difference is that you can get a dependency on BigInt by just writing a big integer literal but to get a dependency on BigFloat you need to use something explicit e.g. the |
It would be a breaking change, but it could parse as a |
I don't want What are the pros and cons of it as a stdlib, or included at all? I want to suggest users use ArbNumerics.jl OR MPFR.jl but not usually at the same time so I could do: const BigFloat = ArbNumerics.ArbFloat i.e. add that to that package, and it would work as a faster drop-in replacement, for most users. |
undefined, or I guess you rather mean:
couldn't that, and all other cases you mention be handled by that erroring definition and/or defining in a package, pirating? E.g.
it's not clear it's best to get BigFloat out (with its default 256 bits), the next step for widen should be to 128 bits I recall you get for ArbNumerics.ArbFloat, its default is settable, to e.g. 256 bits, hypothetically you could widen to higher and higher or to MPFR. The first step is to figure out how to deal with the fact that e.g. big integers are a part of the syntax of the language:
It seems you made an invalid point since you get Int128 up to: Meta.parse("170141183460469231731687303715884105728") # On higher than the typemax, there's also UInt128. I think we could just error in the parser (for a slight technically breaking change, who depends on that large integer literals, in the parser? Note if you add .0 the this turns into a Float64, not BigFloat) and it wouldn't be awfully bad. And support for BigInt can be dynamically added to the parser(?), Julia doesn't need BigInt for itself (in the parser). It's possibly easier to add to the parser at runtime with JuliaSyntax.jl now used, if that's actually advised...
The reason I don't like this much is that the users that want BigInt may not need or want BigFloat and vice versa. Eventually we should have a BigInt (external or stdlib) library (or name it GMP.jl?), in addition to for We could have
|
FWIW array hashing no longer uses |
BigFloat
could be moved to a stdlib package (BigFloats
?MPFR
?), though there are a few places it is coupled to Base:widen(::Float64)
andbig(::AbstractFloat)
widen
)Should be doable viaI misunderstood what theTwicePrecision
trickswiden
was for.@irrational
macro, which defines aBigFloat
methodFloat64(::Irrational,::RoundingMode)
(which is used in floating point inequalities)Rational{T}(::Irrational)
andrationalize(::T,::Irrational)
c.f. https://discourse.julialang.org/t/moving-bigfloat-to-stdlib/8545
The text was updated successfully, but these errors were encountered: