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

fix28 overflow #4

Open
rs1729 opened this issue Mar 15, 2024 · 0 comments
Open

fix28 overflow #4

rs1729 opened this issue Mar 15, 2024 · 0 comments

Comments

@rs1729
Copy link

rs1729 commented Mar 15, 2024

VGA_Graphics/Mandelbrot_Set/mandelbrot_fixvfloat.c

if ((Zre_sq + Zim_sq) >= FOURfix28) break ;

The fix28 values Zre_sq + Zim_sq can overflow, resulting in artifacts.
You can mitigate the problem a little by

    if ((unsigned)(Zre_sq + Zim_sq) > (unsigned)FOURfix28) break;

(or using fix27, but losing precision).
However some points remain for which the iterates will overflow.
Probably better to check for potential overflow before the escape check (affects only iterates outside the circle)

    if (Zre < -TWOfix28 || Zre > TWOfix28) break;
    if (Zim < -TWOfix28 || Zim > TWOfix28) break;

    if ((unsigned)(Zre_sq + Zim_sq) > (unsigned)FOURfix28) break;

In principle the rectangle check is an escape check, so it would also work (the rectangle contains the circle), but the contour lines outside the Mandelbrot set would look different.

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

No branches or pull requests

1 participant