18c95af84Sbostic /*- 2*967dd0d9Sbostic * Copyright (c) 1991, 1993 3*967dd0d9Sbostic * The Regents of the University of California. All rights reserved. 48c95af84Sbostic * 58c95af84Sbostic * %sccs.include.redist.c% 68c95af84Sbostic */ 78c95af84Sbostic 88c95af84Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*967dd0d9Sbostic static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 06/04/93"; 108c95af84Sbostic #endif /* LIBC_SCCS and not lint */ 118c95af84Sbostic 128c95af84Sbostic #include <sys/types.h> 138c95af84Sbostic #include <math.h> 148c95af84Sbostic 158c95af84Sbostic double frexp(value,eptr)168c95af84Sbosticfrexp(value, eptr) 178c95af84Sbostic double value; 188c95af84Sbostic int *eptr; 198c95af84Sbostic { 208c95af84Sbostic union { 218c95af84Sbostic double v; 228c95af84Sbostic struct { 238c95af84Sbostic u_int u_sign : 1; 248c95af84Sbostic u_int u_exp : 8; 258c95af84Sbostic u_int u_mant1 : 23; 268c95af84Sbostic u_int u_mant2 : 32; 278c95af84Sbostic } s; 288c95af84Sbostic } u; 298c95af84Sbostic 308c95af84Sbostic if (value) { 318c95af84Sbostic u.v = value; 328c95af84Sbostic *eptr = u.s.u_exp - 128; 338c95af84Sbostic u.s.u_exp = 128; 348c95af84Sbostic return(u.v); 358c95af84Sbostic } else { 368c95af84Sbostic *eptr = 0; 378c95af84Sbostic return((double)0); 388c95af84Sbostic } 398c95af84Sbostic } 40