Hi Anuj,

Thanks for the reference:
> This happens because of underflow, if you check the `solve_cubic_equation'
> function 
> (https://github.com/preversewharf45/freetype2-sdf/blob/dcedba69423fc169a9ca95b6391902e1cf27e0b6/src/sdfgen.c#L490)
> there is a term `q3' which is cube of term `q'. So, in cases where is `q' is
> pretty small `q3' becomes zero. And later in the algorithm we have to take
> the `cube_root' of the term (q3 + r2) to find the final roots. Now because of
> underflow the impact of `q' on the final output is zero. That is why the roots
> davaiate and we get a wrong value. In some cases the deviation is quite high.

Do you know from your floating point version if q3 or r2 is larger
when this happens? From your description it sounds like q3 is still
larger than r2.
In this case, if (r2 == 0) is missing here:
https://github.com/preversewharf45/freetype2-sdf/blob/dcedba69423fc169a9ca95b6391902e1cf27e0b6/src/sdfgen.c#L577


Alexei

Reply via email to