fabsh.c 385 Bytes
// fabsh - select between hardware and software implementation of half FP ABS function

#include "extmath.h"
#include <stdint.h>

//#if !(SOFT_FOPS_HALF & EXTMATH_FPOP_MASK_ABS)
//  #error NO HW FSQRTH implementation
//#endif

// software implementation
half fabsh(half x)
{
  uint16_t ix;
  GET_HALF_WORD(ix,x);
  ix = *((uint16_t *)&x) & 0x7fff;
  SET_HALF_WORD(x,ix);
  return x;
}