11.3Smartin/* $NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin 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 * 191.1Smycroft * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Smycroft * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Smycroft * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Smycroft * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Smycroft * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Smycroft * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Smycroft * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Smycroft * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Smycroft * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Smycroft * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Smycroft * POSSIBILITY OF SUCH DAMAGE. 301.1Smycroft */ 311.1Smycroft 321.1Smycroft#include <sys/cdefs.h> 331.1Smycroft#if defined(LIBC_SCCS) && !defined(lint) 341.3Smartin__RCSID("$NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); 351.1Smycroft#endif /* LIBC_SCCS and not lint */ 361.1Smycroft 371.1Smycroft#include <sys/types.h> 381.1Smycroft#include <machine/ieee.h> 391.1Smycroft#include <math.h> 401.1Smycroft 411.1Smycroft/* 421.1Smycroft * ldexp(value, exp): return value * (2 ** exp). 431.1Smycroft */ 441.1Smycroftdouble 451.2Sdrochnerldexp(value, exp2) 461.1Smycroft double value; 471.2Sdrochner int exp2; 481.1Smycroft{ 491.1Smycroft double temp; 501.1Smycroft 511.1Smycroft __asm ("fscalel %2,%1" 521.1Smycroft : "=f" (temp) 531.2Sdrochner : "0" (value), "g" (exp2)); 541.1Smycroft return (temp); 551.1Smycroft} 56