PIPS
exp.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "arithmetique.h"
#include "linear_assert.h"
+ Include dependency graph for exp.c:

Go to the source code of this file.

Functions

Value exponentiate (Value x, int n)
 package arithmetique More...
 

Function Documentation

◆ exponentiate()

Value exponentiate ( Value  x,
int  n 
)

package arithmetique

exp.c

INTLIBRARY no overflow is checked int exponentiate(x,n): raise x to the power n

Precondition: n => 0

validation - n is positive

FI: la complexite pourrait etre reduite de O(n) a O(log n)

Definition at line 45 of file exp.c.

46 {
47  Value y;
48 
49  /* validation - n is positive
50  */
51  assert(n >= 0);
52  if (n == 0) return VALUE_ONE;
53 
54  /* FI: la complexite pourrait etre reduite de O(n) a O(log n)
55  */
56  for(y=VALUE_ONE; n>0; n--)
57  value_product(y,x);
58 
59  return y;
60 }
int Value
#define value_product(v, w)
#define VALUE_ONE
#define assert(ex)
Definition: newgen_assert.h:41
static char * x
Definition: split_file.c:159

References assert, VALUE_ONE, value_product, and x.

Referenced by integer_power_to_transformer().

+ Here is the caller graph for this function: