ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

exp.c
Go to the documentation of this file.
00001 /* Math functions for i387.
00002    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by John C. Bowman <bowman@ipp-garching.mpg.de>, 1995.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <math.h>
00023 
00024 double exp (double __x);
00025 
00026 double exp (double __x)
00027 {
00028 #ifdef __GNUC__
00029   register double __value, __exponent;
00030   __asm __volatile__
00031     ("fldl2e                    # e^x = 2^(x * log2(e))\n\t"
00032      "fmul      %%st(1)         # x * log2(e)\n\t"
00033      "fst       %%st(1)\n\t"
00034      "frndint                   # int(x * log2(e))\n\t"
00035      "fxch\n\t"
00036      "fsub      %%st(1)         # fract(x * log2(e))\n\t"
00037      "f2xm1                     # 2^(fract(x * log2(e))) - 1\n\t"
00038      : "=t" (__value), "=u" (__exponent) : "0" (__x));
00039   __value += 1.0;
00040   __asm __volatile__
00041     ("fscale"
00042      : "=t" (__value) : "0" (__value), "u" (__exponent));
00043 
00044   return __value;
00045 #else
00046   register double __val;
00047   __asm
00048   {
00049     fld1                        // store 1.0 for later use
00050     fld __x
00051     fldl2e                      // e^x = 2^(x * log2(e))
00052     fmul    st,st(1)            // x * log2(e)
00053     fld     st(0)
00054     frndint                     // int(x * log2(e))
00055     fsub    st,st(1)            // fract(x * log2(e))
00056     fxch
00057     f2xm1                       // 2^(fract(x * log2(e))) - 1
00058     fadd    st,st(3)            // + 1.0
00059     fscale
00060     fstp __val
00061   }
00062   return __val;
00063 #endif /*__GNUC__*/
00064 }

Generated on Sun May 27 2012 04:36:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.