Xavier Del Campo Romero
33a383b98e
libfixmath/fix16.h: replace static const with define
...
This allows using them with compile-time expressions.
2022-02-24 21:45:25 +01:00
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
Petteri Aimonen
c4a480774a
Fix compiler warning in fix16_abs()
2021-04-29 09:50:32 +03:00
Martin Bařinka
35eb7753d2
New unittests ( #28 )
...
Refactor unittests
2021-04-29 09:40:06 +03:00
maruncz
ba0991de3e
fixed: signed integer overflow is undefined behavior
2021-04-27 11:08:33 +02: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
David Lechner
3b7f96f982
Add explicit cast in fix16_from_dbl()
...
This fixes the error:
implicit conversion from 'float' to 'double' to match other operand
of binary expression
When the compiler options -fsingle-precision-constant -Wdouble-promotion
are set
2019-06-16 15:19:01 -05:00
Gaëtan Harter
f8596fbada
Fix '-Werror=shift-negative-value' for gcc 6
...
GCC 6 introduced warning for shift on negative value numbers.
When F16C is called with a negative number it evaluates FIXMATH_COMBINE_I_M
with both the positive and the negative value.
Fixes #3
2017-09-28 17:06:54 +02:00
PetteriAimonen
cbbfe85a4a
Add F16C() macro for defining values without float support.
...
Implementation by Jonas Zeiger.
2014-12-30 18:41:55 +00:00
Petteri.Aimonen
10af3a6c60
Add shorthand macro F16() for defining numeric constants
2012-08-30 16:52:52 +00:00
Petteri.Aimonen
543e39f42d
Added to/from string conversion functions, and testcases for them.
2012-08-29 14:38:36 +00:00
Petteri.Aimonen
4ffed9b5ff
Const allows more optimizations than pure
2012-08-05 16:16:12 +00:00
Petteri.Aimonen
40ef134f4d
Add fix16_sq() inline function as a shorthand to square values
2012-08-05 16:11:40 +00:00
Flatmush
fb944f6adc
Added abs, floor, ceil, min, max, clamp.
...
More code cleanup.
2012-07-25 10:38:03 +00:00
Flatmush
71eed13ecf
Added log base 2 functions kindly provided by Tev Olsen.
2012-07-25 10:24:47 +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
9169c3663c
Fix the check around 'leaf' attribute, which is supported only by GCC > 4.6.
2012-05-06 09:09:16 +00:00
Petteri.Aimonen
91c5422472
Fix useless warning on AVR
2012-02-27 16:44:21 +00:00
Petteri.Aimonen
e929442f71
Improved fix16_exp() (half runtime, more accuracy), added fix16_log(), made unittests for both.
2012-02-27 16:40:07 +00:00
Petteri.Aimonen
eb1cb67561
Added some function attributes when using GCC; these may help the optimizer a bit.
2012-01-27 15:06:46 +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
5248e45183
Faster atan2 algorithm (about twice faster), same precision
2011-06-09 12:32:50 +00:00
vincent.del.medico
716d5fa179
Added a new algo for sin() function, and a small error analysis to show the precision differences
2011-06-08 22:46:14 +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
joe.schaack
88b4ee4c0e
I assume you mean to subtract the two for the ssub function...
2011-03-02 19:56:20 +00:00
flatmush
e8ab51042b
Added fix16_add, fix16_sub, fix16_ssub as static inline functions.
...
Updated C++ interface to include saturated operators.
2011-03-02 16:33:28 +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
5dd63f37ce
Updated sin lut to use ~200KiB for it's table with the same accuracy, the lookup table implementation tends to run at about 33-36% of the speed of sinf on my machine (Intel T5500).
...
Fixed a bug in the sin lut code so that the results are always accurate.
Changed fixsingen tool to generate tables correctly for the new implementation.
2011-02-25 16:07:39 +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