Commit Graph

81 Commits

Author SHA1 Message Date
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
Xavier Del Campo Romero 151798a2b2 libfixmath/CMakeLists.txt: avoid glob matching 2022-02-24 21:45:25 +01:00
Xavier Del Campo Romero 84a5a3e9b3 libfixmath/CMakeLists.txt: use target_include_directories 2022-02-24 21:45:25 +01:00
Xavier Del Campo Romero f0cb4e0f38 Rename library CMakeLists.txt 2022-02-24 21:45:25 +01:00
Johannes Ringler 64d851a6f9 fix unsigned signed comparison in fix16_fft 2022-02-23 08:50:12 +02:00
Johannes Ringler 09d10c16d3 fix warnings due to signed char on some platforms
some context:
https://stackoverflow.com/a/10186479/1976323
2022-02-23 08:50:12 +02:00
Johannes Ringler 29ddf649e1
fix unused variable warning with FIXMATH_FAST_SIN (#35) 2022-02-10 08:54:05 +02: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
maruncz 17a6197819 fix formatting 2021-04-22 09:10:50 +02:00
maruncz edcfdea949 fixed some warnings 2021-04-21 15:08:15 +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
Chris Hammond 2859cbf31d Added unit tests for "lerp" functions, and found several type conversion bugs 2020-10-22 16:24:49 -04:00
Martin Larralde 950d51759b
Fix `elif` without condition in `fix16_trig.c` 2020-03-15 02:22:25 +01:00
David Lechner d09f7a4396
add #include <stdint.h> to int64.h
When using the `gcc -M` option to determine header file dependencies, int64.h causes an error because the types from stdint.h are not defined.
2019-12-12 17:02:53 -06:00
Martin Larralde 6f6284807f
Fix missing function when building without overflow support 2019-09-08 15:28:05 +02:00
David Lechner 11855068c3 Fix conflict with __int64_t typedef
On Linux, we get a compile error because __int64_t is defined and
included by stdint.h. Double underscores are reseved in C in general
and should not be used anyway. Replace with a single leading underscore.
2019-06-16 15:38:23 -05:00
David Lechner ff0a5f69c2 add FIXMATH_NO_CTYPE option
When compiling with -nostdlib, the functions in ctype may not be
available. Add FIXMATH_NO_CTYPE option to replace them with inline
functions.

Also add unit test to test str functions with this option enabled.
2019-06-16 15:38:19 -05: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
Vitaly Puzrin f13c322287
Suppress `-Wconversion` warning 2019-04-15 02:29:08 +03: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
Xin Li a2784ee999 make some member functions const 2017-08-08 13:54:48 -07:00
PetteriAimonen cbbfe85a4a Add F16C() macro for defining values without float support.
Implementation by Jonas Zeiger.
2014-12-30 18:41:55 +00:00
PetteriAimonen bffee79f7f Fix compile error on GCC 2014-01-16 19:15:34 +00:00
PetteriAimonen 6758096516 Fix errors on Visual Studio (patch by sunside227) 2014-01-16 06:21:59 +00:00
PetteriAimonen 6d59de5d60 Add #ifndefs around sdiv/smul/sadd/ssub in the C++ interface.
Closes issue #19.
2013-01-28 15:56:00 +00: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
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 85204f4a28 Updated coding style document.
Cleaned up some code.
2012-07-25 14:49:11 +00:00
Flatmush bc77d6a360 Added basic code style document to project. 2012-07-25 11:18:25 +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
Flatmush c2a48b8910 Added a patch to make operator results constant in the C++ interface as suggested in Issue 15. 2012-07-02 16:07:50 +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 681fd5aea1 Back to previous Makefile I unintentionally modified 2011-06-11 10:11:11 +00:00
vincent.del.medico 495b0a23ad Added a fix16_sqr32 function, which computes sqrt with reduced 64-bit operations (and without any 64-bit operations by setting FIXMATH_NO_64BIT) 2011-06-11 10:03:17 +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
vincent.del.medico 5248e45183 Faster atan2 algorithm (about twice faster), same precision 2011-06-09 12:32:50 +00:00