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