Xref: news2.mv.net comp.lang.c:56548 comp.lang.c++:72617 comp.os.msdos.djgpp:1127 gnu.g++.help:4636 gnu.gcc.help:5828 From: rfg AT monkeys DOT com (Ronald F. Guilmette) 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: 15 Feb 1996 01:23:58 -0800 Organization: Infinite Monkeys & Co. Lines: 33 Message-ID: <4fuu3e$6c9@segfault.monkeys.com> References: <4ej9lb$mpc AT fu-berlin DOT de> <4eqc7l$ugh AT godzilla DOT zeta DOT org DOT au> <4eqtu3$ddo AT der DOT twinsun DOT com> NNTP-Posting-Host: segfault.monkeys.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article , Tanmoy Bhattacharya wrote: >In article <4eqtu3$ddo AT der DOT twinsun DOT com> eggert AT twinsun DOT com (Paul >Eggert) writes: > > 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. > >I do not agree with this interpretation, as the footnote (technically, >not part of the standard) clarifies: an assignment and cast both must >truncate the result to the required precision... As must the act of returning a result from a function... according to the official response to one Defect Report which was filed against the standard. -- -- Ron Guilmette, Roseville, CA -------- Infinite Monkeys & Co. ------------ ---- E-mail: rfg AT monkeys DOT com ----------- Purveyors of Compiler Test Suites - ------ Copyright (c) 1996 by Ronald F. Guilmette; All rights reserved. -----