Dev:ETL make check

From Synfig Studio :: Documentation
Revision as of 07:08, 22 February 2010 by Zelgadis (Talk | contribs) (moved Source:ETL make check to Dev:ETL make check)

(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, and 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)