59 #define SHIFT_ONE_BYTE (8u)
62 #define SHIFT_TWO_BYTES (16u)
65 #define SHIFT_FOUR_BYTES (32u)
89 const float x_interpolate) {
92 if (fabsf(x1 - x2) >= FLT_EPSILON) {
94 slope = (y2 - y1) / (x2 - x1);
102 float y_interpolate = y1 + (slope * (x_interpolate - x1));
104 return y_interpolate;
112 const uint32_t alternating2PatternStartFF = 0xFF00FF00u;
113 const uint32_t alternating2PatternStart00 = 0x00FF00FFu;
114 const uint32_t intermediate = ((val <<
SHIFT_ONE_BYTE) & alternating2PatternStartFF) |
120 const uint64_t alternating2PatternStartFF = 0xFF00FF00FF00FF00uLL;
121 const uint64_t alternating2PatternStart00 = 0x00FF00FF00FF00FFuLL;
122 const uint64_t alternating4PatternStartFFFF = 0xFFFF0000FFFF0000uLL;
123 const uint64_t alternating4PatternStart0000 = 0x0000FFFF0000FFFFuLL;
125 uint64_t intermediate = ((val <<
SHIFT_ONE_BYTE) & alternating2PatternStartFF) |
127 intermediate = ((intermediate <<
SHIFT_TWO_BYTES) & alternating4PatternStartFFFF) |
133 return fminf(value1, value2);
137 uint8_t returnvalue = value1;
138 if (returnvalue > value2) {
139 returnvalue = value2;
145 uint16_t returnvalue = value1;
146 if (returnvalue > value2) {
147 returnvalue = value2;
153 int32_t absValue = INT32_MAX;
154 if (value != INT32_MIN) {
155 absValue = labs(value);
161 int64_t absValue = INT64_MAX;
162 if (value != INT64_MIN) {
163 absValue = llabs(value);
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
int32_t MATH_AbsInt32_t(const int32_t value)
Returns the absolute value of passed int32_t value.
float MATH_LinearInterpolation(const float x1, const float y1, const float x2, const float y2, const float x_interpolate)
Linear inter-/extrapolates a third point according to two given points.
uint16_t MATH_SwapBytesUint16_t(const uint16_t val)
Swap bytes of uint16_t value.
int64_t MATH_AbsInt64_t(const int64_t value)
Returns the absolute value of passed int64_t value.
uint16_t MATH_MinimumOfTwoUint16_t(const uint16_t value1, const uint16_t value2)
Returns the minimum of the passed uint16_t values.
uint32_t MATH_SwapBytesUint32_t(const uint32_t val)
Swap bytes of uint32_t value.
void MATH_StartupSelfTest(void)
: self test for math functions that can be called at startup
uint8_t MATH_MinimumOfTwoUint8_t(const uint8_t value1, const uint8_t value2)
Returns the minimum of the passed uint8_t values.
float MATH_MinimumOfTwoFloats(const float value1, const float value2)
Returns the minimum of the passed float values.
uint64_t MATH_SwapBytesUint64_t(const uint64_t val)
Swap bytes of uint64_t value.
math library for often used math functions