From owner-bug-octave at bevo dot che dot wisc dot edu Thu Dec 19 13:21:37 1996 Subject: Re: fscanf reads strange values on Octave 2.0 /linux From: "John W. Eaton" To: Tapani Stipa cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 19 Dec 1996 13:21:04 -0600 On 19-Dec-1996, Tapani Stipa wrote: : I would be very much for the option that Octave should read its native : precision with the "%f" format, as some sort of intuition would suggest (I : think Matlab does it this way? cannot test now ... this would of course : not be an excuse by itself ...). I think this makes sense. I've appended a patch if you'd like to try it. : Just wondering: is there any need to read single precision floats if there : is no internal format for them? The only reason that I can think of is that you might want to see what the representation will be if the number is read as a float first. But that doesn't seem like a very good reason now. Thanks, jwe Thu Dec 19 12:13:42 1996 John W. Eaton * oct-stream.cc (octave_base_stream::do_scanf): Don't treat %l{e,f,g} differently from %{e,f,g}. (octave_base_stream::do_oscanf): Likewise. Index: oct-stream.cc =================================================================== RCS file: /home/jwe/src/master/octave/src/oct-stream.cc,v retrieving revision 1.11 diff -c -r1.11 oct-stream.cc *** oct-stream.cc 1996/12/08 04:02:46 1.11 --- oct-stream.cc 1996/12/19 19:16:15 *************** *** 887,895 **** --- 887,897 ---- do_scanf_conv (istream&, const char*, int*, Matrix&, double*, int&, int, int, bool); + #if 0 template void do_scanf_conv (istream&, const char*, float*, Matrix&, double*, int&, int, int, bool); + #endif template void do_scanf_conv (istream&, const char*, double*, Matrix&, double*, int&, *************** *** 982,1001 **** case 'e': case 'f': case 'g': { ! if (elt->modifier == 'l') ! { ! double tmp; ! ! do_scanf_conv (is, fmt, &tmp, mval, data, ! count, nr, max_size, discard); ! } ! else ! { ! float tmp; ! do_scanf_conv (is, fmt, &tmp, mval, data, ! count, nr, max_size, discard); ! } } break; --- 984,993 ---- case 'e': case 'f': case 'g': { ! double tmp; ! do_scanf_conv (is, fmt, &tmp, mval, data, count, ! nr, max_size, discard); } break; *************** *** 1231,1238 **** --- 1223,1232 ---- template octave_value do_oscanf_num_conv (istream&, const char*, int*, bool); + #if 0 template octave_value do_oscanf_num_conv (istream&, const char*, float*, bool); + #endif template octave_value do_oscanf_num_conv (istream&, const char*, double*, bool); *************** *** 1298,1315 **** case 'e': case 'f': case 'g': { ! if (elt->modifier == 'l') ! { ! double tmp; ! retval = do_oscanf_num_conv (is, fmt, &tmp, discard); ! } ! else ! { ! float tmp; ! ! retval = do_oscanf_num_conv (is, fmt, &tmp, discard); ! } } break; --- 1292,1300 ---- case 'e': case 'f': case 'g': { ! double tmp; ! retval = do_oscanf_num_conv (is, fmt, &tmp, discard); } break;