-
Notifications
You must be signed in to change notification settings - Fork 252
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
arb_get_str() & arb_set_str() does not preserve value #2208
Comments
Neither |
@albinahlback Thanks, I am aware of that. I am not saying that the implementation breaks the documentation. |
Then what is your issue? You asked if |
My question was: Shouldn't |
Note that this is somewhat related to flintlib/arb#391. In flintlib/arb#391 I wonder if both methods could be more careful when it's possible not to introduce any error. |
I have been trying to get this right for a while, testing various approaches and they all end like this: using Serialization, ArbNumerics function Serialization.serialize(s::AbstractSerializer, x::ArbFloat) function Serialization.deserialize(s::AbstractSerializer, ::Type{ArbFloat{P}}) where {P} low_precision = 53 setworkingprecision(low_precision) arf_val = log(ArbFloat(17)) 2.83321334405621608serialize_buffer = Serializer(IOBuffer()) Serializer{IOBuffer}(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false,size=0, maxsize=Inf, ptr=1, mark=-1), 0, IdDict{Any, Any}(),Int64[], Dict{UInt64, Any}(), 26)serialize(serialize_buffer, arf_val) Serializer{IOBuffer}(IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false,size=82, maxsize=Inf, ptr=83, mark=-1), 3, IdDict{Any, Any}(:ArbNumerics => 2, ArbFloat{64} => 0, :ArbFloat => 1),Int64[], Dict{UInt64, Any}(), 26)arf_val_recovered = deserialize(serialize_buffer, typeof(arf_val)) |
@fredrik-johansson can you transfer this issue to FLINT? |
@JeffreySarnoff can you provide a MWE in C for your issue? Also, please use code blocks to format the code. |
@saraedum So the issue is that when you use string methods, you convert between a binary and a decimal representation on an inexact ring. This forces a loss of information. |
Consider the following C program.
When run (with Arb 2.22.1 from conda-forge) it prints:
I understand that
arb_get_str()
can introduce imprecision and I also understand that I should probably usearb_dump_str
to serialize anarb_t
; but shouldn'tarb_set_str()
preserve the radius?The text was updated successfully, but these errors were encountered: