From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 115914,eb58654c5683eea0 X-Google-Attributes: gid115914,public X-Google-Thread: 10cebf,eb58654c5683eea0 X-Google-Attributes: gid10cebf,public X-Google-Thread: 1164f8,eb58654c5683eea0 X-Google-Attributes: gid1164f8,public From: Philippe Pouliquen Subject: Re: VAX D-Float format Date: 1997/11/06 Message-ID: <3461DAA6.41C6@alpha.ece.jhu.edu> X-Deja-AN: 287818116 References: <34575f82.182344367@serve.installshield.com> <63aalh$7rj@usenet.pa.dec.com> <345e03ce.617620030@serve.installshield.com> <63q51i$8qa@usenet.pa.dec.com> Organization: The Johns Hopkins University, Electrical and Computer Engineering Department Newsgroups: comp.sys.dec,comp.sys.dec.micro,comp.arch.arithmetic Steve Lionel wrote: > |>On 30 Oct 1997 15:55:29 GMT, lionel@mail.dec.com (Steve Lionel) wrote: > |>> Type Exponent bits Exponent bias Fraction bits (including hidden) > |>> ========================================================================== > |>> F 8 128 24 > |>> D 8 128 56 > |>> G 11 1024 53 > |>> H 15 16384 113 S 8 127 24 (IEEE single precision) T 11 1023 53 (IEEE double precision) I've added the IEEE floating point info from the alpha architecture reference manual for comparison (the alpha supports both IEEE and VAX formats, but will drop the last three mantissa bits when operating on D_floating). > In VAX floating, the fraction is 0.F, not 1.F as it is in IEEE float. I believe you meant "...the fraction is 0.1F not 1.F...". Both the VAX formats and the IEEE format do not include the redundant most significant fraction bit (this is what is meant by "hidden 1"). > -- > Steve Lionel mailto:Steve.Lionel@digital.com > Fortran Development http://www.digital.com/info/slionel.html > Digital Equipment Corporation > 110 Spit Brook Road, ZKO2-3/N30 > Nashua, NH 03062-2698 "Free advice is worth every cent" > > For information on DIGITAL Fortran, see http://www.digital.com/fortran Here is the generic bit pattern for the VAX and IEEE floats: Sign Exponent Mantissa IEEE value VAX value 0 0111...101 000...000 2^-2=0.25 2^-3=0.125 0 0111...110 000...000 2^-1=0.5 2^-2=0.25 0 0111...111 000...000 2^0=1 2^-1=0.5 0 1000...000 000...000 2^1=2 2^0=1 0 1000...001 000...000 2^2=4 2^1=2 0 1000...010 000...000 2^3=8 2^2=4 1 0111...111 000...000 -(2^0)=-1 -(2^-1)=-0.5 1 1000...000 000...000 -(2^1)=-2 -(2^0)=-1 You will note that in every case, F_floating and S_floating differ by a factor of 2, and G_floating and T_floating also differ by a factor of 2. A D_floating is just a F_floating with an extra 32 bits of mantissa. Here are some more examples with non-zero mantissa: 0 0111...111 100...000 (1.5)*(2^0)=1.5 (1.5)*(2^-1)=0.75 0 1000...000 100...000 (1.5)*(2^1)=3 (1.5)*(2^0)=1.5 So you have some D_floating data, and you want to process it with a modern IEEE compliant machine? (and you don't want to buy an alpha running VMS?) Here's what you would want to do with the bits: D_floating bits: F_floating bits: G_floating bits: H_floating bits: sign: D63 F31=D63 G63=D63 H127=D63 e D62 F30=D62 G62=D62 H126=D62 x D61 F29=D61 G61=D61 H125=D61 p G60=D61 H124=D61 o G59=D61 H123=D61 n G58=D61 H122=D61 e H121=D61 n H120=D61 t H119=D61 H118=D61 D60 F28=D60 G57=D60 H117=D60 D59 F27=D59 G56=D59 H116=D59 D58 F26=D58 G55=D58 H115=D58 D57 F25=D57 G54=D57 H114=D57 D56 F24=D56 G53=D56 H113=D56 D55 F23=D55 G52=D55 H112=D55 m D54 F22=D54 G51=D54 H111=D54 a D53 F21=D53 G50=D53 H110=D53 n D52 F20=D52 G49=D52 H109=D52 t . . . . . . . i . . . . . . . s . . . . . . . s D34 F2 =D34 G31=D34 H91 =D34 a D33 F1 =D33 G30=D33 H90 =D33 D32 F0 =D32 G29=D32 H89 =D32 D31 G28=D31 H88 =D31 D30 G27=D30 H87 =D30 D29 G26=D29 H86 =D29 . . . . . . . . . . . . . . . D5 G2 =D5 H62 =D5 D4 G1 =D4 H61 =D4 D3 G0 =D3 H60 =D3 D2 H59 =D2 D1 H58 =D1 D0 H57 =D0 H56 = 0 H55 = 0 H54 = 0 . . H2 = 0 H1 = 0 H0 = 0 Once you have the correct VAX format, convert to the same size IEEE format by dividing by 2. Hope this helps and sets this issue to rest. (I also hope I didn't make a typo :-) Philippe Pouliquen Electrical and Computer Engineering Johns Hopkins University Baltimore, USA