1*47049Sbostic /*- 2*47049Sbostic * Copyright (c) 1991 The Regents of the University of California. 3*47049Sbostic * All rights reserved. 4*47049Sbostic * 5*47049Sbostic * %sccs.include.redist.c% 6*47049Sbostic */ 7*47049Sbostic 8*47049Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*47049Sbostic static char sccsid[] = "@(#)frexp.c 5.1 (Berkeley) 03/06/91"; 10*47049Sbostic #endif /* LIBC_SCCS and not lint */ 11*47049Sbostic 12*47049Sbostic #include <sys/types.h> 13*47049Sbostic #include <math.h> 14*47049Sbostic 15*47049Sbostic double 16*47049Sbostic frexp(value, eptr) 17*47049Sbostic double value; 18*47049Sbostic int *eptr; 19*47049Sbostic { 20*47049Sbostic union { 21*47049Sbostic double v; 22*47049Sbostic struct { 23*47049Sbostic u_int u_sign : 1; 24*47049Sbostic u_int u_exp : 8; 25*47049Sbostic u_int u_mant1 : 23; 26*47049Sbostic u_int u_mant2 : 32; 27*47049Sbostic } s; 28*47049Sbostic } u; 29*47049Sbostic 30*47049Sbostic if (value) { 31*47049Sbostic u.v = value; 32*47049Sbostic *eptr = u.s.u_exp - 128; 33*47049Sbostic u.s.u_exp = 128; 34*47049Sbostic return(u.v); 35*47049Sbostic } else { 36*47049Sbostic *eptr = 0; 37*47049Sbostic return((double)0); 38*47049Sbostic } 39*47049Sbostic } 40