From owner-bug-octave at bevo dot che dot wisc dot edu Thu Dec 19 01:17:01 1996 Subject: Re: fscanf reads strange values on Octave 2.0 /linux From: Tapani Stipa To: "John W. Eaton" cc: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 19 Dec 1996 09:13:07 +0200 (EET) On Wed, 18 Dec 1996, John W. Eaton wrote: > If you use "%lf", I think you will get the result you expect. Indeed. Thank you for the hint. There seems to be some contradiction between this behaviour and the info manuals: >> Numeric Input Conversions ------------------------- This section describes the `scanf' conversions for reading numeric values. The `%d' conversion matches an optionally signed integer in decimal radix. The `%i' conversion matches an optionally signed integer in any of the formats that the C language defines for specifying an integer constant. For example, any of the strings `10', `0xa', or `012' could be read in as integers under the `%i' conversion. Each of these specifies a number with decimal value `10'. The `%o', `%u', and `%x' conversions match unsigned integers in octal, decimal, and hexadecimal radices, respectively. The `%X' conversion is identical to the `%x' conversion. They both permit either uppercase or lowercase letters to be used as digits. Unlike the C language `scanf', Octave ignores the `h', `l', and `L' modifiers. << > However, I'm not sure that Octave should try to follow the semantics > of C this closely. Perhaps it would be more useful if "%f" and "%lf" > were equivalent. Does anyone have any strong opinions either way? 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 ...). Just wondering: is there any need to read single precision floats if there is no internal format for them? Best Regards, Tapani -- Tapani Stipa, Finnish Institute of Marine Research PL 33, FI-00931 HELSINKI, Finland tel. +358-9-613 941 fax +358-9-613 94 494