Blame sysdeps/ieee754/ldbl-96/s_iscanonicall.c

Packit 6c4009
/* Test whether long double value is canonical.  ldbl-96 version.
Packit 6c4009
   Copyright (C) 2016-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <float.h>
Packit 6c4009
#include <math.h>
Packit 6c4009
#include <math_private.h>
Packit 6c4009
#include <stdbool.h>
Packit 6c4009
#include <stdint.h>
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
__iscanonicall (long double x)
Packit 6c4009
{
Packit 6c4009
  uint32_t se, i0, i1 __attribute__ ((unused));
Packit 6c4009
Packit 6c4009
  GET_LDOUBLE_WORDS (se, i0, i1, x);
Packit 6c4009
  int32_t ix = se & 0x7fff;
Packit 6c4009
  bool mant_high = (i0 & 0x80000000) != 0;
Packit 6c4009
Packit 6c4009
  if (LDBL_MIN_EXP == -16381)
Packit 6c4009
    /* Intel variant: the high mantissa bit should have a value
Packit 6c4009
       determined by the exponent.  */
Packit 6c4009
    return ix > 0 ? mant_high : !mant_high;
Packit 6c4009
  else
Packit 6c4009
    /* M68K variant: both values of the high bit are valid for the
Packit 6c4009
       greatest and smallest exponents, while other exponents require
Packit 6c4009
       the high bit to be set.  */
Packit 6c4009
    return ix == 0 || ix == 0x7fff || mant_high;
Packit 6c4009
}
Packit 6c4009
libm_hidden_def (__iscanonicall)