cmath.tcc revision 132720
1151937Sjkim// -*- C++ -*- C math library.
2151937Sjkim
3151937Sjkim// Copyright (C) 2000, 2003, 2004 Free Software Foundation, Inc.
4151937Sjkim//
5151937Sjkim// This file is part of the GNU ISO C++ Library.  This library is free
6151937Sjkim// software; you can redistribute it and/or modify it under the
7217365Sjkim// terms of the GNU General Public License as published by the
8298714Sjkim// Free Software Foundation; either version 2, or (at your option)
9151937Sjkim// any later version.
10151937Sjkim
11217365Sjkim// This library is distributed in the hope that it will be useful,
12217365Sjkim// but WITHOUT ANY WARRANTY; without even the implied warranty of
13217365Sjkim// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14217365Sjkim// GNU General Public License for more details.
15217365Sjkim
16217365Sjkim// You should have received a copy of the GNU General Public License along
17217365Sjkim// with this library; see the file COPYING.  If not, write to the Free
18217365Sjkim// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19217365Sjkim// USA.
20217365Sjkim
21217365Sjkim// As a special exception, you may use this file as part of a free software
22217365Sjkim// library without restriction.  Specifically, if other files instantiate
23217365Sjkim// templates or use macros or inline functions from this file, or you compile
24217365Sjkim// this file and link it with other files to produce an executable, this
25151937Sjkim// file does not by itself cause the resulting executable to be covered by
26217365Sjkim// the GNU General Public License.  This exception does not however
27217365Sjkim// invalidate any other reasons why the executable file might be covered by
28217365Sjkim// the GNU General Public License.
29151937Sjkim
30217365Sjkim// This file was written by Gabriel Dos Reis <gdr@codesourcery.com>
31217365Sjkim
32217365Sjkim#ifndef _GLIBCXX_CMATH_TCC
33217365Sjkim#define _GLIBCXX_CMATH_TCC 1
34217365Sjkim
35217365Sjkimnamespace std
36217365Sjkim{
37217365Sjkim  template<typename _Tp>
38217365Sjkim    inline _Tp
39217365Sjkim    __cmath_power(_Tp __x, unsigned int __n)
40217365Sjkim    {
41217365Sjkim      _Tp __y = __n % 2 ? __x : 1;
42217365Sjkim
43151937Sjkim      while (__n >>= 1)
44151937Sjkim        {
45151937Sjkim          __x = __x * __x;
46151937Sjkim          if (__n % 2)
47151937Sjkim            __y = __y * __x;
48151937Sjkim        }
49151937Sjkim
50151937Sjkim      return __y;
51151937Sjkim    }
52151937Sjkim}
53151937Sjkim
54151937Sjkim#endif
55151937Sjkim