SYSTEM@YMIR.BITNET (09/22/87)
> The caviat is to not MIX mode on the various statements if at all possible. Yo u > could fall victim to a rounding error by the compiler should happen to have th e > right (wrong) value specified. The impact of this is to put decimal points aft er > the numbers that you are comparing to and performing math with. Now some will > look at the machine code, as I did, and say that there will be no savings in > time since conversions to floating point values is done by the Fortran compile r, > and they would be right. I have to ask about the rest of the languages and if > they are as smart (?) as the Fortran compiler on VAX. The various compilers under VMS deal with rounding, conversion and arithmetic in general on constants in different ways. VMS FORTRAN carries out all its floating point operations on constants in H_floating, regardless of the precision the constant is actually specified in. Constants are only truncated down to the precision that is actually used in the final stages of code generation. I remember finding out about this in a talk given at DECUS; my experiences with VMS FORTRAN have tended to verify it, but I have never tried really testing it extensively. Behavior like this is very nice and friendly, but it presents a real problem when you cannot figure out why your double precision code works differently on another system that does no use this extension to the FORTRAN standard. VMS Pascal, on the other hand, follows its own language rules for type conversion when doing constant arithmetic operations. For example, if you assign a value as follows: VAR a : double; BEGIN a := 1.2345678901234567890e0; ... the value actually assigned to A will be truncated down to a single precision value, so you get something like 1.2345679. If you change the "e0" to a "d0" you will get the full complement of digits. This is quite annoying to me, but since it follows a strict sense of type conversion it really is the natural way for Pascal to behave. VAX BASIC, despite the compiler's FORTRAN ancestry, seems to work more like Pascal, although who can really tell given the peculiarities of BASIC semantics?? VAX C may be even more interesting in this regard, given C's propensity for performing all floating point operations in double precision... Anyone who uses C care to comment on this? Ned Freed