Skip to content

Calculate number of representable values between two BigFloats #29

@exoriente

Description

@exoriente

Hi @stencillogic,

Is there a way to determine how close two BigFloats are to each other in terms of number of representable values, given a certain precision? I need it for an application in which I want to gradually increase precision and discover automatically whether or not it's time to increase precision as the algorithm zooms in further.

Some background: As a practice project to take some first steps in the Rust language, I'm building a small application that allows you to explore the Mandelbrot fractal. It allows the user to zoom in further and further into an area in the complex plane and I'm enlarging smaller and smaller parts of the fractal to render them on screen. Currently I'm using f64 to represent the complex coordinates, but that allows you to zoom in only so far. I would like to switch to BigFloat and to increase the precision automatically when necessary. I'm looking for a way to judge whether the current precision still suffices.

Is there a way to do something like this: n = representable_values_between(x, y, p) with n being an integer representing the number of floating point values that can be represented at precision p, that are larger or equal than x and smaller than y?

Let me know if the issue is clear. If not, I can explain further.

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