octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #45687] fread does not allow different ARCH wh


From: Emmanuel Goua de Baix
Subject: [Octave-bug-tracker] [bug #45687] fread does not allow different ARCH when file fopen'd with ARCH
Date: Tue, 11 Aug 2015 08:24:09 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0

Follow-up Comment #8, bug #45687 (project octave):

Rik, your results with the corrected version seem OK for me.
Here are the results when displaying the values (same as yours except that
obviously I still get the error for b/ieee-le since I made no change to my
Octave):


Octave V4.0.0
fopen ARCH nothing | fread ARCH nothing => OK
fopen ARCH ieee-le | fread ARCH nothing => ans =   2.1787e+005
fopen ARCH ieee-be | fread ARCH nothing => ans =   2.7444e-307
fopen ARCH       b | fread ARCH nothing => ans =   2.7444e-307
fopen ARCH nothing | fread ARCH  native => ans =   2.1787e+005
fopen ARCH ieee-le | fread ARCH  native => ans =   2.1787e+005
fopen ARCH ieee-be | fread ARCH  native => ERROR !
fopen ARCH       b | fread ARCH  native => ERROR !
fopen ARCH nothing | fread ARCH ieee-be => ans =   2.7444e-307
fopen ARCH ieee-le | fread ARCH ieee-be => ans =   2.7444e-307
fopen ARCH ieee-be | fread ARCH ieee-be => ans =   2.7444e-307
fopen ARCH       b | fread ARCH ieee-be => ans =   2.7444e-307
fopen ARCH nothing | fread ARCH ieee-le => ans =   2.1787e+005
fopen ARCH ieee-le | fread ARCH ieee-le => ans =   2.1787e+005
fopen ARCH ieee-be | fread ARCH ieee-le => ERROR !
fopen ARCH       b | fread ARCH ieee-le => ERROR !

ML 2010a (reformatted for better reading)
fopen ARCH nothing | fread ARCH nothing => OK
fopen ARCH ieee-le | fread ARCH nothing => ans =  2.1787e+005
fopen ARCH ieee-be | fread ARCH nothing => ans =  2.7444e-307
fopen ARCH       b | fread ARCH nothing => ans =  2.7444e-307
fopen ARCH nothing | fread ARCH  native => ans =  2.1787e+005
fopen ARCH ieee-le | fread ARCH  native => ans =  2.1787e+005
fopen ARCH ieee-be | fread ARCH  native => ans =  2.1787e+005
fopen ARCH       b | fread ARCH  native => ans =  2.1787e+005
fopen ARCH nothing | fread ARCH ieee-be => ans =  2.7444e-307
fopen ARCH ieee-le | fread ARCH ieee-be => ans =  2.7444e-307
fopen ARCH ieee-be | fread ARCH ieee-be => ans =  2.7444e-307
fopen ARCH       b | fread ARCH ieee-be => ans =  2.7444e-307
fopen ARCH nothing | fread ARCH ieee-le => ans =  2.1787e+005
fopen ARCH ieee-le | fread ARCH ieee-le => ans =  2.1787e+005
fopen ARCH ieee-be | fread ARCH ieee-le => ans =  2.1787e+005
fopen ARCH       b | fread ARCH ieee-le => ans =  2.1787e+005


Now that I think of it, the results b/nothing are unexpected: it behaves like
b/ieee-be instead of b/native.
The documentation of Octave about fread() is silent about the default value
but the documentation of ML states that 'native' is the default ARCH. Still in
fread()'s doc, I think there is no reference about the ARCH used by fopen().
No reference about ARCH used by fread() neither in fopen().

So I feel like the implementation of fread() uses the ARCH of fopen() by
default, not necessarly 'native'. The documentation of ML is wrong on this
point.

I discovered this issue with a binary file written by a C program where int
are big-endian and float are little-endian.
One can also imagine a file where some floats are LE and some others are BE
(headaches granted !).
I think that the feature to let the programmer force the ARCH in fread()
independantly to the one used by fopen() is good and shall remain IMHO.


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?45687>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]