2018-03-05 12:37 AM
Hello, I'm STM8S user.
I doing find the STM8S math.h, math.s in stm8s code example.. But i dont find it,,
I want to use ABS(X) ,, ABS(X) isnt there in math.h?
2018-03-05 01:27 AM
Hello
,if you cannot find ABS function, you can make your own:
#define ABS(x) ((x) > 0 ? (x) : -(x))�?
Best regards,
Tilen
2018-03-05 02:47 AM
I guess you want to use abs(). The name is in lower-case, and it is in stdlib.h.
Philipp
P.S.: However, if you want to handle floating-point numbers, you should use fabsf(), which is in math.h. Variants for different types exist both for integer (labs(), llabs()) and floating-point (fabs(), fabsl(), but those don't matter on STM8 as no current compiler supports double or long double).