source: trunk/libs/newlib/src/newlib/libm/common/s_fpclassify.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 897 bytes
Line 
1/* Copyright (C) 2002, 2007 by  Red Hat, Incorporated. All rights reserved.
2 *
3 * Permission to use, copy, modify, and distribute this software
4 * is freely granted, provided that this notice is preserved.
5 */
6
7#include "fdlibm.h"
8
9int
10__fpclassifyd (double x)
11{
12  __uint32_t msw, lsw;
13
14  EXTRACT_WORDS(msw,lsw,x);
15
16  if ((msw == 0x00000000 && lsw == 0x00000000) ||
17      (msw == 0x80000000 && lsw == 0x00000000))
18    return FP_ZERO;
19  else if ((msw >= 0x00100000 && msw <= 0x7fefffff) ||
20           (msw >= 0x80100000 && msw <= 0xffefffff))
21    return FP_NORMAL;
22  else if ((msw >= 0x00000000 && msw <= 0x000fffff) ||
23           (msw >= 0x80000000 && msw <= 0x800fffff))
24    /* zero is already handled above */
25    return FP_SUBNORMAL;
26  else if ((msw == 0x7ff00000 && lsw == 0x00000000) ||
27           (msw == 0xfff00000 && lsw == 0x00000000))
28    return FP_INFINITE;
29  else
30    return FP_NAN;
31}
Note: See TracBrowser for help on using the repository browser.