1*af3276d5Sguenther /* $OpenBSD: ldexp.c,v 1.5 2015/10/27 05:54:49 guenther Exp $ */
2118f6189Smickey
3118f6189Smickey /*-
4118f6189Smickey * Copyright (c) 1990 The Regents of the University of California.
5118f6189Smickey * All rights reserved.
6118f6189Smickey *
7118f6189Smickey * This code is derived from software contributed to Berkeley by
8118f6189Smickey * Charles Hannum.
9118f6189Smickey *
10118f6189Smickey * Redistribution and use in source and binary forms, with or without
11118f6189Smickey * modification, are permitted provided that the following conditions
12118f6189Smickey * are met:
13118f6189Smickey * 1. Redistributions of source code must retain the above copyright
14118f6189Smickey * notice, this list of conditions and the following disclaimer.
15118f6189Smickey * 2. Redistributions in binary form must reproduce the above copyright
16118f6189Smickey * notice, this list of conditions and the following disclaimer in the
17118f6189Smickey * documentation and/or other materials provided with the distribution.
18118f6189Smickey * 3. Neither the name of the University nor the names of its contributors
19118f6189Smickey * may be used to endorse or promote products derived from this software
20118f6189Smickey * without specific prior written permission.
21118f6189Smickey *
22118f6189Smickey * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23118f6189Smickey * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24118f6189Smickey * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25118f6189Smickey * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26118f6189Smickey * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27118f6189Smickey * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28118f6189Smickey * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29118f6189Smickey * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30118f6189Smickey * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31118f6189Smickey * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32118f6189Smickey * SUCH DAMAGE.
33118f6189Smickey */
34118f6189Smickey
35b30a1762Sderaadt #include <math.h>
36b30a1762Sderaadt
37118f6189Smickey /*
38118f6189Smickey * ldexp(value, exp): return value * (2 ** exp).
39118f6189Smickey */
40118f6189Smickey
41118f6189Smickey double
ldexp(double value,int exp)42118f6189Smickey ldexp(double value, int exp)
43118f6189Smickey {
44118f6189Smickey double temp;
45118f6189Smickey __asm ("fscale"
46118f6189Smickey : "=t" (temp)
47118f6189Smickey : "0" (value), "u" ((double)exp));
48118f6189Smickey return (temp);
49118f6189Smickey }
50*af3276d5Sguenther DEF_STRONG(ldexp);
51