ecragg@GMUVAX.GMU.EDU ("EDWARD CRAGG") (06/04/90)
The following (edited) thread from INFO-VAX would appear to be of interest to the INFO-ADA community. ............................................................................. Subj: VAX Float Types in specific, Ada's DIGITS attribute in general From: EDU%"usc!trwind!mcosm!sroka@UCSD.EDU" "Gabriel D. Sroka" 31-MAY-1990 06:00:45.56 From: EDU%"F.Zwarts%KVI.nl@CUNYVM.CUNY.EDU" "Fred Zwarts, KVI, Groningen, NL." 1-JUN-1990 13:24:45.62 From: WINS%"kassover@ra.crd.ge.com" Sroka > QUESTION: Sroka > Why does the VAX Ada v2.0 LRM [3.5.7] say that D_FLOATs have 9 digits Sroka > of precision (d.o.p.)? I think they have 16 d.o.p. Sroka > Sroka > DATA: Sroka > Fig. 2-2 in the VAX Ada Run-Time Reference Manual (RTRM) indicates that Sroka > D_FLOATs have 56-bit fractions. Fig. 2-3 indicates that G_FLOATs have Sroka > 53-bit fractions. Sroka > Sroka > PREMISE: Sroka > A float with an (N+3)-bit fraction should have as many as or more Sroka > digits of precision than another float with an N-bit fraction. Sroka > I think D_FLOATs have 16 d.o.p. ("one part in 2**55" as it says at Sroka > the top of 2-13.) I think G_FLOATs have 15 d.o.p. ("one part in 2**52" Sroka > as it says on 2-14.) Zwarts > Carefull read LRM [3.5.7] again. You will notice that in a Zwarts > floating point declaration the DIGITS keyword does not only specify Zwarts > the precision, but also the exponential range. Zwarts > Zwarts > "The specified number D is the minimal number of decimal digits Zwarts > required ..." "The value of D in turn determines a corresponding Zwarts > number B that is the minimum number of binary digits ..." "The model Zwarts > numbers defined ... comprise zero and all numbers whose binary Zwarts > canonical form has exactly B digits after the point in the mantissa Zwarts > and an exponent in the range -4*B .. +4*B." Zwarts > Zwarts > Therefore a floating point type with more than 9 DIGITS cannot be Zwarts > represented by a D_FLOAT type. Zwarts > Zwarts > The exponential range and the precision are very much out of balance Zwarts > (for Ada) for a D_FLOAT type. For a G_FLOAT type this balance is much Zwarts > better, therefore it can be used with a larger value of DIGITS. Kassover > I might add that if, for some reason, you have to import a Kassover > routine written in a language other than Ada that must pass a Kassover > long_float, make sure all such routines are compiled with a /G_FLOAT Kassover > or other suitable qualifier. Kassover > Kassover > Otherwise, your Ada program will get the right number of bits, Kassover > that may or may not represent a number that is reasonable for Kassover > your calculation. Kassover > Kassover > If such recompilation is not an option, you will have to find or Kassover > build a conversion routine or two...