8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / gen / common / frexp.c
blobffc75618b1a666b2a50238a93bd7f15c7dd6d9c3
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
22 #pragma ident "%Z%%M% %I% %E% SMI" /* from UCB 5.2 3/9/86 */
25 * the call
26 * x = frexp(arg,&exp);
27 * must return a double fp quantity x which is <1.0
28 * and the corresponding binary exponent "exp".
29 * such that
30 * arg = x*2^exp
32 double
33 frexp(x, i)
34 double x;
35 int *i;
37 int neg, j;
39 j = 0;
40 neg = 0;
41 if (x<0) {
42 x = -x;
43 neg = 1;
45 if (x>=1.0)
46 while (x>=1.0) {
47 j = j+1;
48 x = x/2;
50 else if (x < 0.5 && x != 0.0)
51 while(x<0.5) {
52 j = j-1;
53 x = 2*x;
55 *i = j;
56 if(neg)
57 x = -x;
58 return (x);