From maintainers-request at octave dot org Fri Jul 23 09:59:22 2004 Subject: VAX<-->IEEE 32bit float conversion From: "John W. Eaton" To: Wolfgang Westphal Cc: octave maintainers mailing list Date: Thu, 22 Jul 2004 16:27:51 -0400 You are correct that there is just one 4-byte VAX floating point format. Octave should call this VAX_F, not VAX_D and VAX_G. OTOH, I think the Matlab data file format only includes options for D and G. In any case, I don't think the conversion can be as simple as your code suggests. The format described here http://h18009.www1.hp.com/fortran/docs/unix-um/dfumcompat.htm#index_x_3983 looks like this: 31 16 15 14 7 6 0 | fraction | sign | exponent | fraction | * Bit 15 is the sign bit (0 for positive numbers, 1 for negative numbers). * Bits 14:7 are a binary exponent in excess 128 notation (binary exponents from --127 to 127 are represented by binary 1 to 255). * Bits 6:0 and 31:16 are a normalized 24-bit fraction with the redundant most significant fraction bit not represented. It looks like your code does not account for the fact that there are only 7 bits in the first part of the fraction. Or am I missing something? Perhaps it worked for you because of the particular range of values you used for testing? Please note that I've moved this discussion to the maintainers list. Thanks, jwe On 1-Jun-2004, Wolfgang Westphal wrote: | Hi! | | I had to read some data files containing float values in VAX notation, | so I've implemented the conversion for 32bit VAX floats to IEEE little | endian. AFAIK for the 32bit case there's no difference between "VAX-D" | and "VAX-G", so the conversion is identical in both cases. | | The attached patch is tested in octave 2.1.50 as well as octave 2.1.57, | and worksforme. | | Regards, | Wolfgang Westphal | --- liboctave/data-conv.cc 2002-04-10 02:39:51.000000000 +0200 | +++ liboctave/data-conv.cc 2004-05-31 13:10:14.000000000 +0200 | at @ -277,15 +277,26 @@ | } | | static void | -VAX_D_float_to_IEEE_little_float (float * /* d */, int /* len */) | +VAX_D_float_to_IEEE_little_float (float * d, int len) | { | - gripe_data_conversion ("VAX D float", "IEEE little endian format"); | + for (int i=0;i