60 #define SHIFT_ONE_BYTE (8u)
63 #define SHIFT_TWO_BYTES (16u)
66 #define SHIFT_FOUR_BYTES (32u)
91 const float x_interpolate) {
94 if (fabsf(x1 - x2) >= FLT_EPSILON) {
96 slope = (y2 - y1) / (x2 - x1);
104 float y_interpolate = y1 + (slope * (x_interpolate - x1));
106 return y_interpolate;
114 const uint32_t alternating2PatternStartFF = 0xFF00FF00u;
115 const uint32_t alternating2PatternStart00 = 0x00FF00FFu;
116 const uint32_t intermediate = ((val <<
SHIFT_ONE_BYTE) & alternating2PatternStartFF) |
122 const uint64_t alternating2PatternStartFF = 0xFF00FF00FF00FF00uLL;
123 const uint64_t alternating2PatternStart00 = 0x00FF00FF00FF00FFuLL;
124 const uint64_t alternating4PatternStartFFFF = 0xFFFF0000FFFF0000uLL;
125 const uint64_t alternating4PatternStart0000 = 0x0000FFFF0000FFFFuLL;
127 uint64_t intermediate = ((val <<
SHIFT_ONE_BYTE) & alternating2PatternStartFF) |
129 intermediate = ((intermediate <<
SHIFT_TWO_BYTES) & alternating4PatternStartFFFF) |
135 return fminf(value1, value2);
139 uint8_t returnvalue = value1;
140 if (returnvalue > value2) {
141 returnvalue = value2;
147 uint16_t returnvalue = value1;
148 if (returnvalue > value2) {
149 returnvalue = value2;
155 int32_t absValue = INT32_MAX;
156 if (value != INT32_MIN) {
157 absValue = labs(value);
163 int64_t absValue = INT64_MAX;
164 if (value != INT64_MIN) {
165 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