From owner-freebsd-questions Mon Feb 7 16: 7: 8 2000 Delivered-To: freebsd-questions@freebsd.org Received: from web124.yahoomail.com (web124.yahoomail.com [205.180.60.192]) by builder.freebsd.org (Postfix) with SMTP id 586E940A5 for ; Mon, 7 Feb 2000 16:06:52 -0800 (PST) Received: (qmail 14330 invoked by uid 60001); 7 Feb 2000 23:44:27 -0000 Message-ID: <20000207234427.14329.qmail@web124.yahoomail.com> Received: from [209.25.106.139] by web124.yahoomail.com; Mon, 07 Feb 2000 15:44:27 PST Date: Mon, 7 Feb 2000 15:44:27 -0800 (PST) From: Fabio Miranda Subject: Floating point expection - Core dumped To: freebsd-questions@FreeBSD.ORG MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include #include 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