1*ce099b40Smartin /* $NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */
2f784c984Smycroft
3f784c984Smycroft /*-
4f784c984Smycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
5f784c984Smycroft * All rights reserved.
6f784c984Smycroft *
7f784c984Smycroft * This code is derived from software contributed to The NetBSD Foundation
8f784c984Smycroft * by Charles M. Hannum.
9f784c984Smycroft *
10f784c984Smycroft * Redistribution and use in source and binary forms, with or without
11f784c984Smycroft * modification, are permitted provided that the following conditions
12f784c984Smycroft * are met:
13f784c984Smycroft * 1. Redistributions of source code must retain the above copyright
14f784c984Smycroft * notice, this list of conditions and the following disclaimer.
15f784c984Smycroft * 2. Redistributions in binary form must reproduce the above copyright
16f784c984Smycroft * notice, this list of conditions and the following disclaimer in the
17f784c984Smycroft * documentation and/or other materials provided with the distribution.
18f784c984Smycroft *
19f784c984Smycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20f784c984Smycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21f784c984Smycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22f784c984Smycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23f784c984Smycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24f784c984Smycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25f784c984Smycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26f784c984Smycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27f784c984Smycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28f784c984Smycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29f784c984Smycroft * POSSIBILITY OF SUCH DAMAGE.
30f784c984Smycroft */
31f784c984Smycroft
32f784c984Smycroft #include <sys/cdefs.h>
33f784c984Smycroft #if defined(LIBC_SCCS) && !defined(lint)
34*ce099b40Smartin __RCSID("$NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin Exp $");
35f784c984Smycroft #endif /* LIBC_SCCS and not lint */
36f784c984Smycroft
37f784c984Smycroft #include <sys/types.h>
38f784c984Smycroft #include <machine/ieee.h>
39f784c984Smycroft #include <math.h>
40f784c984Smycroft
41f784c984Smycroft /*
42f784c984Smycroft * ldexp(value, exp): return value * (2 ** exp).
43f784c984Smycroft */
44f784c984Smycroft double
ldexp(value,exp2)45f0f40184Sdrochner ldexp(value, exp2)
46f784c984Smycroft double value;
47f0f40184Sdrochner int exp2;
48f784c984Smycroft {
49f784c984Smycroft double temp;
50f784c984Smycroft
51f784c984Smycroft __asm ("fscalel %2,%1"
52f784c984Smycroft : "=f" (temp)
53f0f40184Sdrochner : "0" (value), "g" (exp2));
54f784c984Smycroft return (temp);
55f784c984Smycroft }
56