1130766Sdas/*-
2130766Sdas * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
3130766Sdas * All rights reserved.
4130766Sdas *
5130766Sdas * Redistribution and use in source and binary forms, with or without
6130766Sdas * modification, are permitted provided that the following conditions
7130766Sdas * are met:
8130766Sdas * 1. Redistributions of source code must retain the above copyright
9130766Sdas *    notice, this list of conditions and the following disclaimer.
10130766Sdas * 2. Redistributions in binary form must reproduce the above copyright
11130766Sdas *    notice, this list of conditions and the following disclaimer in the
12130766Sdas *    documentation and/or other materials provided with the distribution.
13130766Sdas *
14130766Sdas * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15130766Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16130766Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17130766Sdas * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18130766Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19130766Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20130766Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21130766Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22130766Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23130766Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24130766Sdas * SUCH DAMAGE.
25130766Sdas */
26130766Sdas
27130766Sdas#include <sys/cdefs.h>
28130766Sdas__FBSDID("$FreeBSD$");
29130766Sdas
30143219Sdas#include <limits.h>
31130766Sdas#include <math.h>
32130766Sdas
33130766Sdasdouble
34130766Sdasscalbln (double x, long n)
35130766Sdas{
36143219Sdas	int in;
37130766Sdas
38143219Sdas	in = (int)n;
39143219Sdas	if (in != n) {
40143219Sdas		if (n > 0)
41143219Sdas			in = INT_MAX;
42143219Sdas		else
43143219Sdas			in = INT_MIN;
44143219Sdas	}
45143219Sdas	return (scalbn(x, in));
46130766Sdas}
47130766Sdas
48130766Sdasfloat
49130766Sdasscalblnf (float x, long n)
50130766Sdas{
51143219Sdas	int in;
52130766Sdas
53143219Sdas	in = (int)n;
54143219Sdas	if (in != n) {
55143219Sdas		if (n > 0)
56143219Sdas			in = INT_MAX;
57143219Sdas		else
58143219Sdas			in = INT_MIN;
59143219Sdas	}
60143219Sdas	return (scalbnf(x, in));
61130766Sdas}
62143219Sdas
63143219Sdaslong double
64143219Sdasscalblnl (long double x, long n)
65143219Sdas{
66143219Sdas	int in;
67143219Sdas
68143219Sdas	in = (int)n;
69143219Sdas	if (in != n) {
70143219Sdas		if (n > 0)
71143219Sdas			in = INT_MAX;
72143219Sdas		else
73143219Sdas			in = INT_MIN;
74143219Sdas	}
75143219Sdas	return (scalbnl(x, (int)n));
76143219Sdas}
77