2 * From: @(#)s_ilogb.c 5.1 93/09/24
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
10 * ====================================================
13 #include <sys/cdefs.h>
14 __FBSDID("$FreeBSD$");
30 if (u.bits.exp == 0) {
31 if ((u.bits.manl | u.bits.manh) == 0) { /* x == 0 */
36 if (u.bits.manh == 0) {
37 m = 1lu << (LDBL_MANL_SIZE - 1);
38 for (b = LDBL_MANH_SIZE; !(u.bits.manl & m); m >>= 1)
41 m = 1lu << (LDBL_MANH_SIZE - 1);
42 for (b = 0; !(u.bits.manh & m); m >>= 1)
45 #ifdef LDBL_IMPLICIT_NBIT
48 return ((long double)(LDBL_MIN_EXP - b - 1));
50 if (u.bits.exp < (LDBL_MAX_EXP << 1) - 1) /* normal */
51 return ((long double)(u.bits.exp - LDBL_MAX_EXP + 1));
52 else /* +/- inf or nan */