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