www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/03/11:42:19

Xref: news2.mv.net comp.lang.c:54950 comp.lang.c++:70534 comp.os.msdos.djgpp:757 gnu.g++.help:4486 gnu.gcc.help:5691
From: eggert AT twinsun DOT com (Paul Eggert)
Newsgroups: comp.lang.c,comp.lang.c++,gnu.gcc.help,gnu.g++.help,comp.os.msdos.djgpp
Subject: Re: float != float and floats as return types
Date: 1 Feb 1996 09:40:19 -0800
Organization: Twin Sun Inc, El Segundo, CA, USA
Lines: 15
Message-ID: <4eqtu3$ddo@der.twinsun.com>
References: <4ej9lb$mpc AT fu-berlin DOT de> <4elnjj$er4 AT server2 DOT rz DOT uni-leipzig DOT de> <4eqc7l$ugh AT godzilla DOT zeta DOT org DOT au>
NNTP-Posting-Host: der.twinsun.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

bde AT zeta DOT org DOT au (Bruce Evans) writes:

>    a = 1.0;
>    b = FLT_EPSILON / 4.0;
>    c = a + b;
>    assert(c == (float) (a + b));

As far as I can tell the C Standard allows the assertion to either
succeed or fail, depending on the implementation.  The key phrase in
the standard is ``The values of floating operands and of the results of
floating expressions may be represented in greater precision and range
than that required by the type''.  So `c' might be represented in more
bits than `(float) (a + b)' (or vice versa! though this is more
controversial since it contradicts the Rationale, and it may be
corrected by the committee soon), and the assertion might fail.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019