cmath.tcc revision 97403
1115399Skan// -*- C++ -*- C math library. 2115399Skan 3119693Skan// Copyright (C) 2000 Free Software Foundation, Inc. 4119777Skan// 5115399Skan// This file is part of the GNU ISO C++ Library. This library is free 6119693Skan// software; you can redistribute it and/or modify it under the 7119693Skan// terms of the GNU General Public License as published by the 8119693Skan// Free Software Foundation; either version 2, or (at your option) 9119693Skan// any later version. 10119693Skan 11119693Skan// This library is distributed in the hope that it will be useful, 12143946Sdavidxu// but WITHOUT ANY WARRANTY; without even the implied warranty of 13119693Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14119693Skan// GNU General Public License for more details. 15119693Skan 16119693Skan// You should have received a copy of the GNU General Public License along 17119693Skan// with this library; see the file COPYING. If not, write to the Free 18119693Skan// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19119693Skan// USA. 20119693Skan 21119693Skan// As a special exception, you may use this file as part of a free software 22119693Skan// library without restriction. Specifically, if other files instantiate 23119693Skan// templates or use macros or inline functions from this file, or you compile 24119693Skan// this file and link it with other files to produce an executable, this 25119693Skan// file does not by itself cause the resulting executable to be covered by 26119693Skan// the GNU General Public License. This exception does not however 27119693Skan// invalidate any other reasons why the executable file might be covered by 28119693Skan// the GNU General Public License. 29119777Skan 30119693Skan// This file was written by Gabriel Dos Reis <gdr@codesourcery.com> 31119693Skan 32119693Skan#ifndef _CPP_BITS_CMATH_TCC 33119693Skan#define _CPP_BITS_CMATH_TCC 1 34119693Skan 35117179Srunamespace std 36119693Skan{ 37115399Skan export template<typename _Tp> 38119693Skan _Tp 39119693Skan __cmath_power(_Tp __x, unsigned int __n) 40119693Skan { 41 _Tp __y = __n % 2 ? __x : 1; 42 43 while (__n >>= 1) 44 { 45 __x = __x * __x; 46 if (__n % 2) 47 __y = __y * __x; 48 } 49 50 return __y; 51 } 52} 53 54#endif 55