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