ldexp_881.c revision 1.1
11.1Smycroft/*	$NetBSD: ldexp_881.c,v 1.1 1999/08/29 19:41:53 mycroft Exp $	*/
21.1Smycroft
31.1Smycroft/*-
41.1Smycroft * Copyright (c) 1998 The NetBSD Foundation, Inc.
51.1Smycroft * All rights reserved.
61.1Smycroft *
71.1Smycroft * This code is derived from software contributed to The NetBSD Foundation
81.1Smycroft * by Charles M. Hannum.
91.1Smycroft *
101.1Smycroft * Redistribution and use in source and binary forms, with or without
111.1Smycroft * modification, are permitted provided that the following conditions
121.1Smycroft * are met:
131.1Smycroft * 1. Redistributions of source code must retain the above copyright
141.1Smycroft *    notice, this list of conditions and the following disclaimer.
151.1Smycroft * 2. Redistributions in binary form must reproduce the above copyright
161.1Smycroft *    notice, this list of conditions and the following disclaimer in the
171.1Smycroft *    documentation and/or other materials provided with the distribution.
181.1Smycroft * 3. All advertising materials mentioning features or use of this software
191.1Smycroft *    must display the following acknowledgement:
201.1Smycroft *        This product includes software developed by the NetBSD
211.1Smycroft *        Foundation, Inc. and its contributors.
221.1Smycroft * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Smycroft *    contributors may be used to endorse or promote products derived
241.1Smycroft *    from this software without specific prior written permission.
251.1Smycroft *
261.1Smycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Smycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Smycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Smycroft * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Smycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Smycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Smycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Smycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Smycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Smycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Smycroft * POSSIBILITY OF SUCH DAMAGE.
371.1Smycroft */
381.1Smycroft
391.1Smycroft#include <sys/cdefs.h>
401.1Smycroft#if defined(LIBC_SCCS) && !defined(lint)
411.1Smycroft__RCSID("$NetBSD: ldexp_881.c,v 1.1 1999/08/29 19:41:53 mycroft Exp $");
421.1Smycroft#endif /* LIBC_SCCS and not lint */
431.1Smycroft
441.1Smycroft#include <sys/types.h>
451.1Smycroft#include <machine/ieee.h>
461.1Smycroft#include <math.h>
471.1Smycroft
481.1Smycroft/*
491.1Smycroft * ldexp(value, exp): return value * (2 ** exp).
501.1Smycroft */
511.1Smycroftdouble
521.1Smycroftldexp(value, exp)
531.1Smycroft	double value;
541.1Smycroft	int exp;
551.1Smycroft{
561.1Smycroft	double temp;
571.1Smycroft
581.1Smycroft	__asm ("fscalel %2,%1"
591.1Smycroft		: "=f" (temp)
601.1Smycroft		: "0" (value), "g" (exp));
611.1Smycroft	return (temp);
621.1Smycroft}
63