Skip to content

Flag for enabling warnings when converting from AbstractFloat #138

Description

@Joel-Dahne

I find that one of the easiest mistakes to make when working with Arblib in Julia is to accidentally use Float64 for some internal computations. For example for x::Arb it's perfectly fine to do any of the following

2x
x / 2
x^2
π * x
x / π
x^π

But you get a wrong result for, e.g.,

2π * x
x / log(2)
x^(1 / 3) # x^(1 // 3) works though
sqrt(2) * x

One of the common things for all of the wrong examples is that they involve a conversion from AbstractFloat to Arb. The Idea I have had is to have some sort of flag or macro which, when enable, prints a warning whenever a AbstractFloat is converted to Arb. So it would behave something like

function convert(::Type{Arb}, x::AbstractFloat)
    @warn "converting a $(typeof(x)) to Arb, it's possible that this is a mistake."
    return Arb(x)
end

Does this sound interesting to you?

I don't know exactly how this would be implemented, I feel like it should be possible but I don't know exactly how. Any thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions