source: git/factory/cf_util.cc @ ccf43d5

spielwiese
Last change on this file since ccf43d5 was 0494b80, checked in by Jens Schmidt <schmidt@…>, 27 years ago
* cf_util.cc: #include fix git-svn-id: file:///usr/local/Singular/svn/trunk@673 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 615 bytes
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: cf_util.cc,v 1.5 1997-09-09 07:10:22 schmidt Exp $ */
3
4//{{{ docu
5//
6// cf_util.cc - miscellaneous functions, not necessarily related
7//   to canonical forms.
8//
9// Used by: fac_cantzass.cc, gfops.cc
10//
11//}}}
12
13#include <config.h>
14
15//{{{ int ipower ( int b, int m )
16//{{{ docu
17//
18// ipower() - calculate b^m in standard integer arithmetic.
19//
20// Note: Beware of overflows.
21//
22//}}}
23int
24ipower ( int b, int m )
25{
26    int prod = 1;
27
28    while ( m != 0 ) {
29        if ( m % 2 != 0 )
30            prod *= b;
31        m /= 2;
32        if ( m != 0 )
33            b *= b;
34    }
35    return prod;
36}
37//}}}
Note: See TracBrowser for help on using the repository browser.