[comp.lang.modula3] Floating point question

nr@hart.Princeton.EDU (Norman Ramsey) (01/18/91)

If x : REAL, under what circumstances am I guaranteed
	FLOAT(LONGFLOAT(x)) = x?

(I'm uneasy about the ``ties are broken arbitrarily'' language in the
Definition.) 
--
Norman Ramsey
nr@princeton.edu

greeny@wotan.top.cis.syr.edu (Jonathan Greenfield) (01/19/91)

In article <1991Jan18.035540.1@elcgl.epfl.ch> madmats@elcgl.epfl.ch writes:
>> If x : REAL, under what circumstances am I guaranteed
>> 	FLOAT(LONGFLOAT(x)) = x?
>
>I would say Never, in any programming language.

I must disagree with this.  While some languages and  implementations may vary
from doing so, I can see no good reason why the set of representable values
using single precision should not be a subset of the set of representable
values using double precision, regardless of the language.

  Essentially I am saying that there is no justification for a loss of
information due to an INCREASE in precision.  While we know that, in general,
the laws of algebra to not apply to the manipulation of reals in programs,
the law

   FLOAT(LONGFLOAT(x)) = x (for REAL x, and for the operations specified in the
                            Modula-3 language definition)

will hold on any system that provides compatible single- and double-precision
reals, as described above.

The failure to provide compatible single- and double-precision real
representations is undoubtedly a serious flaw for any processor.

Based on the language definition, it is clear that the above law will be
correct for any implementation using compatible real representations.
(Because the statement about 'ties' can only apply when there is no exact
equivalent for the type conversion.)


Jonathan Greenfield