8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libbc / libc / crt / sparc / _ftou.c
blob44c5d7f7eb39d70f62da29069a1d329515cbbe74
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"
25 * Copyright (c) 1987 by Sun Microsystems, Inc.
28 unsigned
29 _dtou(d)
30 double d;
32 /* Convert double to unsigned. */
34 int id;
37 * id = d is correct if 0 <= d < 2**31, and good enough if d is NaN
38 * or d < 0 or d >= 2**32. Otherwise, since the result (int) d of
39 * converting 2**31 <= d < 2**32 is unknown, adjust d before the
40 * conversion.
43 if (d >= 2147483648.0)
44 id = 0x80000000 | (int) (d - 2147483648.0);
45 else
46 id = (int) d;
47 return (unsigned) id;
50 unsigned
51 _ftou(dd)
52 int dd; /* really float */
54 /* Convert float to unsigned. */
56 int id;
57 double d = (double) *((float *)(&dd));
59 * id = d is correct if 0 <= d < 2**31, and good enough if d is NaN
60 * or d < 0 or d >= 2**32. Otherwise, since the result (int) d of
61 * converting 2**31 <= d < 2**32 is unknown, adjust d before the
62 * conversion.
65 if (d >= 2147483648.0)
66 id = 0x80000000 | (int) (d - 2147483648.0);
67 else
68 id = (int) d;
69 return (unsigned) id;