Article View: chile.comp.programacion
Article #3586Re: funcion round en C
From: araguayo
Date: Thu, 09 Dec 2004 21:15
Date: Thu, 09 Dec 2004 21:15
60 lines
2310 bytes
2310 bytes
joe <joe@anonymous.nu> wrote:
: Hola
: Tengo el siguiente problema con la funcion round.
: El programa.
: /***** round.c *****/
: #include <stdio.h>
: #include <math.h>
: int main ()
: {
: double x = 1.234, y;
: y = round(x);
: printf("El valor redondeado de %f es %f.\n", x,y);
: return 0;
: }
: /***** end ****/
:
: Compilacion:
: $ gcc -o round -Wall -lm round.c
: round.c: In function `main':
: round.c:7: warning: implicit declaration of function `round'
: * Ejecucion:
: $ ./round
: El valor redondeado de 1.234000 es -927530976.000000.
: $ gcc --version
: gcc (GCC) 3.3.5 (Debian 1:3.3.5-3)
: [...]
: No cacho que estoy haciendo mal... Alguna idea?
: Saludos!
: --
: joe
Tu programa me funciona bien en un Debian y en un Gentoo.
ias-linux:~# gcc --version
gcc (GCC) 3.3.5 (Debian 1:3.3.5-2)
Podria ser la version pero me da flojera actualizarla en este momento :)
Por alguna razon tu "math.h" no prototipa la funcion double().. sepa moya
porque.. puedes agregar algo del estilo en tu codigo antes del main:
double round(double);
Asi el mensaje desaparece... en el printf poner "%lf" en vez de "%f"..
aunque aquello suele ser intracedente.
----
Ariel Aguayo B. (araguayo@dcc.uchile.cl)
"Vale la pena morir por todo aquello sin lo cual no vale la pena vivir..."
Salvador Allende.
Technical Details
Message-ID:
<cpaf99$l8e$1@helcaraxe.dcc.uchile.cl>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.cec.uchile.cl!helcaraxe.dcc.uchile.cl!not-for-mailReferences:
<cpa338$p9o$1@news1.nivel5.cl>Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,45a58cbd8a22477a
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news.cec.uchile.cl!helcaraxe.dcc.uchile.cl!not-for-mail
From: araguayo@dcc.uchile.cl
Newsgroups: chile.comp.programacion
Subject: Re: funcion round en C
Date: Thu, 9 Dec 2004 21:15:21 +0000 (UTC)
Organization: DCC - Universidad de Chile
Lines: 60
Message-ID: <cpaf99$l8e$1@helcaraxe.dcc.uchile.cl>
References: <cpa338$p9o$1@news1.nivel5.cl>
NNTP-Posting-Host: anakena.dcc.uchile.cl
X-Trace: helcaraxe.dcc.uchile.cl 1102626921 21774 192.80.24.3 (9 Dec 2004 21:15:21 GMT)
X-Complaints-To: newsmaster@dcc.uchile.cl
NNTP-Posting-Date: Thu, 9 Dec 2004 21:15:21 +0000 (UTC)
User-Agent: tin/1.6.2-20030910 ("Pabbay") (UNIX) (Linux/2.6.9-gentoo-r4 (i686))