Date: Mon, 7 Feb 2000 15:44:27 -0800 (PST) From: Fabio Miranda <fmirand@yahoo.com> To: freebsd-questions@FreeBSD.ORG Subject: Floating point expection - Core dumped Message-ID: <20000207234427.14329.qmail@web124.yahoomail.com>
next in thread | raw e-mail | index | archive | help
hi, the following ask for x and n values and realize this funcion : P = (3x+2)/n! * E(n,i=1) (x^(n+1-i)) / (n+1-i)!))^2 I compile it $gcc -o e1 e1.c -lm I compile and works fine on NetBSD and solaris. On FreeBSD compiles good, but when n and x are >= 10, it says "Floating point expection - core dumped" thanks for help, code below: #include <stdio.h> #include <stdlib.h> #include <math.h> main() { /*Declaracion de variables*/ int x, n, a1, i=1, a2=1, temp=1, b1, b2=1, w=1, temp1=1, t, y; double A, B, P, C, sumt=0; /* Inicio */ printf("Estructura de Lenguajes de Programacion\n"); printf("Laboratorio No. 1\n"); printf("Desarrollado por: Fabio Andres Miranda\n"); printf("Compilado en GNU cc sobre FreeBSD (Unix)\n\n"); printf("Use: $ cc -o e1 e1.c -lm\n"); printf(" $ ./e1\n"); printf("----------------------------------------\n"); /* Ingreso de variables */ printf("Por favor, ingrese el valor de x:"); scanf("%d", &x); printf("Por favor, ingrese el valor de n:"); scanf("%d", &n); /* Comprobacion de que n es mayor que cero */ if (n <=0){ printf("\nError: El valor de n (%d) sera usado en funcion factorial y no puede ser menor que cero\n\n", n); return 0; } /* Desarollo del numerador del primer parentesis */ a1 = (3 * x) + 2; /* Factorial de n (n!) */ i = n; while (i != 0) { temp = i; a2 = a2 * temp; i = i - 1; } /* Primer Cociente */ A = (double) a1 / a2; /* Sumatoria */ for ( w = 1; w <= n ; w++) { i = w; t = ( n + 1 - i); /* Numerador */ b1 = pow(x, t); /* Denominador, factorial de (n + 1 -i )! */ y = t; b2 = 1; while(y != 0){ temp = y; b2 = b2 * temp; y = y - 1; } /* Numerador / denominador */ B = (double) b1 / b2; sumt = (double) sumt + B; } C = (double) pow(sumt,2); P = (double) A * C; /* Muestra de resultados */ printf(" \n P = %.4f\n\n ", P); return 0; } __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000207234427.14329.qmail>