Martin Bařinka
0c88e55fa8
fixed division, undefined behaviors and some improvements ( #33 )
...
* testing using ctest
* emove old testing script
* added github workflow CI
* updated CI
* added unit test for macros
* F16() and F16C() are both rounding allways, so fix16_from_dbl should as well
* added tests for strign operations, but these functions are in my opinion unreliable and tests are failing
* removed old unittests
* removed old unittests from cmake
* problem with division using gcc
* improved benchmark
* clarification of problem with division
* attempt to fix
* fixed some undefined behaviors, fixed division
2021-05-03 13:43:54 +03:00
Chris Hammond
18a9ad00de
Removed 64-bit restriction on linear interpolation functions. Added more test cases and fixed several bugs in the 64-bit arithmetic functions.
...
Also added script to run all unit tests.
2020-10-29 13:20:27 -04:00
Chris Hammond
2859cbf31d
Added unit tests for "lerp" functions, and found several type conversion bugs
2020-10-22 16:24:49 -04:00
PetteriAimonen
bf4299bf58
Fix error in fix16_lerp16 on platforms with sizeof(int) == 2.
...
Patch by georgjohann. Closes issue 20.
2013-01-28 15:52:08 +00:00
PetteriAimonen
52214f192f
Use >= comparison in fix16_sadd, fix16_ssub.
...
Patch submitted by georgjohann.
Closes issue #21 .
2013-01-28 15:49:07 +00:00
Petteri.Aimonen
a3ad27ed10
Fix a division bug on 64-bit platforms.
...
The GCC builtin clzl depends on the sizeof(long), which
caused an error if it was other than 32 bits.
Fixes issue #17 .
2012-08-31 10:16:09 +00:00
Flatmush
fb944f6adc
Added abs, floor, ceil, min, max, clamp.
...
More code cleanup.
2012-07-25 10:38:03 +00:00
Flatmush
d9944df6d2
Added some deg/rad conversion functions.
...
Fixed up some code style inconsistencies.
Added a modulo function to allow optimization on 8-bit machines.
2012-07-25 09:54:58 +00:00
Petteri.Aimonen
1076285d26
Merging a bunch of separately developed functions:
...
fix16_mul, fix16_div, fix16_sqrt.
They are faster & more accurate than the previous versions.
Closes issue #13 .
Includes unittests for the functions in question, runnable
by typing 'make' in the unittests folder.
2012-01-26 15:43:30 +00:00
vincent.del.medico
c59675818b
Fixed issue 12 in fix16_div when FIXMATH_NO_64BIT defined
2011-06-10 13:49:11 +00:00
Flatmush
b2e8a96e21
Fixed some compiler errors in int64.h.
...
Fixed and tested ARM assembler version of fix16_mul.
2011-03-16 10:56:29 +00:00
joe.schaack
39d1029807
Changed the #if defined to __thumb2__
...
did not test a compile
2011-03-15 15:48:46 +00:00
Flatmush
8f01005d11
Fixed assembler error in fix16_mul, had used 'or' instead of the correct 'orr' mnemonic.
2011-03-14 21:02:43 +00:00
Flatmush
ccf378f1e0
Fixed a dumb mistake in compilation macros which meant that fix16_mul didn't correctly compile for a certain mix of ARM and Thumb macros.
2011-03-14 20:57:36 +00:00
Flatmush
e83267f757
Changed ARM fix16_mul to be disabled for thumb.
2011-03-13 18:39:26 +00:00
flatmush
98bbaf3b17
Added ARM specific fix16_mul which should be faster, this is untested however so if somebody with an ARM target could compile and check it then I'd be greatful.
2011-03-04 12:42:58 +00:00
flatmush
5fd33d1f98
Updated lerp6 and lerp16 (LinEar inteRPolation) to use the new int64 header so that it can be used with FIXMATH_NO_64BIT.
...
Included "int64.h" in "fixmath.h" so that 64-bit integer support is now part of the libraries functionality.
2011-03-03 11:51:10 +00:00
flatmush
46cb5cd8df
Added C++ class interface.
...
Optimized rounding on 32-bit divide function.
2011-03-02 12:58:08 +00:00
flatmush
9c8a4f9aa9
Updated 32-bit division so it's now actually accurate to within 0.00065% even for non-reciprocals, the algorithm is slightly slower and slightly less accurate than the 64-bit version on my machine though.
...
Added 32-bit tan port using joe's atan2_complex algorithm, this is accurate to 0.0055% when used with the new 32-bit divide.
2011-03-01 15:26:37 +00:00
flatmush
caabb05333
Replaced all macros with static inline functions and static consts for typechecking and easier debugging.
...
Made 32-bit division slightly more accurate and added a TODO comment to make it as accurate as the 64-bit division.
2011-02-28 15:49:51 +00:00
flatmush
047ab9fba0
Updated 32-bit divide, gained 1600% speed increase and an accuracy of 0.00065% (rather than 0.0035%) by multiplying by the reciprocal rather than using a divide algorithm.
2011-02-28 15:04:50 +00:00
flatmush
ae58c98283
Added 32-bit division option, it is less accurate (inaccuracy of ~0.0035%) and very slow (750% of float) but it does work.
...
Changed tan to be saturated (i.e. tan(pi/4) = fix16_max rather than divide by zero error), may revert or implement as stan later.
2011-02-28 11:24:38 +00:00
flatmush
8737eb5fe2
Added FIXMATH_NO_64BIT macro.
...
Implemented multiplication and signed multiplication in 32-bit.
2011-02-28 09:59:36 +00:00
flatmush
8cbe9b3f9b
Added fix16_exp currently using the Taylor Series algorithm off Wikipedia, if anyone can optimize this better then go ahead.
...
Modified fixtest to be a little more generic, can now easily change which function it tests.
2011-02-25 12:08:03 +00:00
Flatmush
7c2852e7f6
Changed conversion functions to macros so that they can be optimized out by the compiler which should make optimized functions much more readable.
...
Implemented FIXMATH_NO_ROUNDING in all multiplication and division functions too, it should now work for all functions in the library and allow for a choice between speed and accuracy on different projects.
2011-02-24 20:04:55 +00:00
flatmush
5d939700e8
Fixed errors in asin/atan, where incorrect integer maths was used.
...
Added a macro (FIXMATH_NO_CACHE) to disable caching.
Added fix16_lerp8 and fix16_lerp32 (should be part of fract module really).
2011-02-23 09:47:08 +00:00
Flatmush
e06f826388
Changed consts such as e, pi, one to macros as suggested by mth for compiler optimization purposes.
2011-02-14 21:53:27 +00:00
Flatmush
3420855dc0
Initial commit. Since its use in fgl and the Dingoo SDK the functions have been separated into more descriptive files/modules.
2011-02-14 20:59:41 +00:00