[ create a new paste ] login | about

Link: http://codepad.org/f3iNFFVp    [ raw code | output | fork ]

C, pasted on Feb 17:
#include <stdio.h>
#include <math.h>
static double rt_powd_snf(double u0, double u1);
static double rt_powd_snf(double u0, double u1)
{
double y;
double d0;
double d1;
if (rtIsNaN(u0) || rtIsNaN(u1)) {
y = rtNaN;
} else {
d0 = fabs(u0);
d1 = fabs(u1);
if (rtIsInf(u1)) {
if (d0 == 1.0) {
y = rtNaN;
} else if (d0 > 1.0) {
if (u1 > 0.0) {
y = rtInf;
} else {
y = 0.0;
}
} else if (u1 > 0.0) {
y = 0.0;
} else {
y = rtInf;
}
} else if (d1 == 0.0) {
y = 1.0;
} else if (d1 == 1.0) {
if (u1 > 0.0) {
y = u0;
} else {
y = 1.0 / u0;
}
} else if (u1 == 2.0) {
y = u0 * u0;
} else if ((u1 == 0.5) && (u0 >= 0.0)) {
y = sqrt(u0);
} else if ((u0 < 0.0) && (u1 > floor(u1))) {
y = rtNaN;
} else {
y = pow(u0, u1);
}
}
return y;
}
void prob1(double n, double App[3])
{
double s;
int i;
/* Ceci est un fichier fonction qui calcule la valeur de pi */
/* avec une série énoncée dans le TP au problème 1. */
s = 0.0;
for (i = 0; i < (int)n; i++) {
s += 4.0 * (rt_powd_snf(-1.0, (1.0 + (double)i) - 1.0) / (2.0 * (1.0 +
(double)i) - 1.0));
}
App[0] = n;
App[1] = s;
App[2] = fabs((s - 3.1415926535897931) / 3.1415926535897931);


Output:
1
2
3
4
5
6
7
In function 'rt_powd_snf':
Line 10: error: 'rtNaN' undeclared (first use in this function)
Line 10: error: (Each undeclared identifier is reported only once
Line 10: error: for each function it appears in.)
Line 19: error: 'rtInf' undeclared (first use in this function)
In function 'prob1':
Line 61: error: expected declaration or statement at end of input


Create a new paste based on this one


Comments: