Article View: es.comp.os.linux.programacion
Article #12951Re: no resta bien en c
From: Jos� Antonio P�rez S�nchez
Date: Wed, 02 May 2001 18:39
Date: Wed, 02 May 2001 18:39
34 lines
2409 bytes
2409 bytes
El d�a Wed, 02 May 2001 11:40:08 +0200, el pensamiento se hizo palabra
en el teclado de Santiago Campos Barrera <santi@essa.net>,
y escribi�:
#> Dado el siguiente programa:
#> [...]
#> Si pones el math.h, hace lo mismo.
#> Si haces un cast de cada uno de los numeros tanto con double, como con
#> float hace lo mismo.
#> Si haces el cast con long double en las 2 restas dice que no es cero.
#>
#> Compilandolo de la siguiente manera:
#> gcc tete.c -o tete
para comparar n�meros reales, adem�s de las opciones dadas por otros
"contertulios", tienes la funci�n fcmp en http://fcmp.sourceforge.net
como dice en la web:
It is generally not wise to compare two floating-point values for exact
equality, for example using the C == operator. The fcmp package
implements Knuth's suggestions for safer floating-point comparison
operators as a C function.
saludos
--
kernel, n.:
A part of an operating system that preserves the medieval
traditions of sorcery and black art.
~~ ^~^ , ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~��~<�>~�~~~~~~~~~~~ o ~~~~~~~~~
('Y') ) Jos� Antonio P�rez S�nchez UiN 82157556 . ()
/ \/ zundrdragon AT ono DOT com Linux User #127782 �<"}}>< �
(\|||/) Debian GNU/Linux ~o~ Kernel 2.4.3 ~o~ PentiumII 350 o
~~~~~~~~~~~��<o>���~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }>((`>� ~~
Technical Details
Message-ID:
<20010502203908.5b6ff5fe.zundrdragon@ono.com>Path:
arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!mu1-ras-7-u-0114.du.onolab.COM!not-for-mailReferences:
<3AEFD5F8.43EF488E@essa.net>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: f86c8,3a88a3fa7399e58 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-05-02 22:35:38 PST Path: arc1-ca.pugleaf.net!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!mu1-ras-7-u-0114.du.onolab.COM!not-for-mail From: Jos� Antonio P�rez S�nchez <zundrdragon@ono.com> Newsgroups: es.comp.os.linux.programacion Subject: Re: no resta bien en c Date: Wed, 2 May 2001 20:39:08 +0200 Organization: High Sorcery Tower ^_^ Lines: 34 Message-ID: <20010502203908.5b6ff5fe.zundrdragon@ono.com> References: <3AEFD5F8.43EF488E@essa.net> NNTP-Posting-Host: mu1-ras-7-u-0114.du.onolab.com (62.42.185.115) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 988868136 15662639 62.42.185.115 (16 [84459]) X-Orig-Path: 127.0.0.1!nobody X-Newsreader: Sylpheed version 0.4.64 (GTK+ 1.2.10; i386-debian-linux-gnu)