Dev:ETL make check

From Synfig Studio :: Documentation
Revision as of 04:27, 8 October 2007 by Dooglus (Talk | contribs) (explain the failure of the 'make check' tests for 'fixed')

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

If we 'make check' in the ETL directory, one of the tests fails.

The failing test is one which multiplies a fixed point number by PI. The result is outside the expected accuracy range.

The problem is that it's working with 12 bits of decimal.

PI is around 12867.9635 * 1/(2^12)

The code in ETL/_fixed.h rounds that down to 12867, and so gets the sum quite wrong.

If it rounded to the nearest integer instead, it would do better.

There are 3 lines in _fixed.h with commented "+0.5" code, like:

fixed_base<T,FIXED_BITS>::fixed_base(const float &f):_data(static_cast<value_type>(f*_ONE()/*+0.5f*/))

If those 3 bits are uncommented, the test passes. I guess it was commented to make the code faster.

Even once that's fixed, however, the 'fixed' check still crashes, when doing:

a=3+i; b=40+i; b/=a;

on all values of i from 1 to 10 million. When i gets to 1048573, 3+i is 2^20, which is represented by shifting it left 12 bits, giving 2^32, which on a machine with 32 bit integers is 0.

So the b/=a line crashes, with:

 Floating point exception(core dumped)