Back to index

glibc  2.9
Functions
ots_nintxq.c File Reference
#include "local-soft-fp.h"

Go to the source code of this file.

Functions

long _OtsNintXQ (long al, long ah, long _round)

Function Documentation

long _OtsNintXQ ( long  al,
long  ah,
long  _round 
)

Definition at line 25 of file ots_nintxq.c.

{
  FP_DECL_EX;
  FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
  unsigned long r;
  long s;

  /* If bit 3 is set, then integer overflow detection is requested.  */
  s = _round & 8 ? 1 : -1;
  _round = _round & 3;

  FP_INIT_ROUNDMODE;
  FP_UNPACK_SEMIRAW_Q(A, a);

  /* Build 0.5 * sign(A) */
  B_e = _FP_EXPBIAS_Q;
  __FP_FRAC_SET_2 (B, 0, 0);
  B_s = A_s;

  FP_ADD_Q(C, A, B);
  _FP_FRAC_SRL_2(C, _FP_WORKBITS);
  _FP_FRAC_HIGH_RAW_Q(C) &= ~(_FP_W_TYPE)_FP_IMPLBIT_Q;
  FP_TO_INT_Q(r, C, 64, s);
  if (s > 0 && (_fex &= FP_EX_INVALID))
    FP_HANDLE_EXCEPTIONS;

  return r;
}