math | developer.brewmp.com math | developer.brewmp.com

Developer

math

Forums:

How to use math functions like abs() using brew api?

Standard C runtime library functions can't be used in BREW. Make use of helper functions available.
- RR.

Standard C runtime library functions can't be used in BREW. Make use of helper functions available.
- RR.

#define abs(x) ((x)>=0 ? (x) : -(x)) //I can't find abs in the brew API...
;)

#define abs(x) ((x)>=0 ? (x) : -(x)) //I can't find abs in the brew API...
;)

In AEEComdef.h
#ifndef ABS
#define ABS(VAL) (((VAL)>0)?(VAL):(-(VAL)))
#endif
and other macros as such MIN, MAX
ruben

In AEEComdef.h
#ifndef ABS
#define ABS(VAL) (((VAL)>0)?(VAL):(-(VAL)))
#endif
and other macros as such MIN, MAX
ruben

double fabs(double d)
{
unsigned *pd = (unsigned*)&d + 1; // don't know word order on big endian phones
*pd = *pd << 1 >> 1;
return d;

double fabs(double d)
{
unsigned *pd = (unsigned*)&d + 1; // don't know word order on big endian phones
*pd = *pd << 1 >> 1;
return d;