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 support ARCH 'ieee-le'


From: Emmanuel Goua de Baix
Subject: [Octave-bug-tracker] [bug #45687] fread does not support ARCH 'ieee-le' for double on 64bits PC
Date: Thu, 06 Aug 2015 11:12:29 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0

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

ARRGG ! B***** H*** ! I found my mistake! Sorry, the bug is more subtle than I
first thought.

Some explanations: Since several people reported that my example worked on
their machine, I tried it again on mine ... and it worked also!
In fact, the example I gave in the original post is a very simplified version
of a Matlab script that I am trying to port for Ocatve.
In this original Matlab script (not written by me), the file is opened with:
fopen(filename, *'r', 'b'*) ... not *'rb'* !!
Stupidly, I didn't pay attention to this, thinking that it was equivalent!
My first tests to write the example was done with "'r','b'". Then for an
unknown reason I written "'rb'" (maybe I was lazy and wanted to save 3 chars
...) in order to test on the 32bits PC. And I didn't try again with "'rb'" on
my 64bits PC. I posted the example with this option, thinking it was a
particular bug on 64bits machine!
Now, after carefully reading the doc of fopen on both Matlab and Octave, I
understand that the third parameter of fopen is an ARCH indicator. 'b' seems
to be a short for 'ieee-be' (undocumented on Ocatve).

So to make it short, my issue seems to be that I tell fopen I work in ieee-be
then I try to read in ieee-le?

I wrote the attached script to test several combinations of ARCH for fopen and
fread.
It prints “OK” when fread succeeds in reading the double in the binary
file attached in original post (it does not check the correctness of the
value). 
It prints “ERROR !“ if an error of fread is caught (assuming it is the
same error as reported in original post)

Here are the results:


% OCTAVE V4.0.0 on BOTH Windows7 64bits AND WindowsXP 32bits unlike announced
in original post
>> test_arch_combinations()
fopen ARCH nothing | fread ARCH nothing => OK
fopen ARCH ieee-le | fread ARCH nothing => OK
fopen ARCH ieee-be | fread ARCH nothing => OK
fopen ARCH       b | fread ARCH nothing => OK
fopen ARCH nothing | fread ARCH  native => OK
fopen ARCH ieee-le | fread ARCH  native => OK
fopen ARCH ieee-be | fread ARCH  native => ERROR !
fopen ARCH       b | fread ARCH  native => ERROR !
fopen ARCH nothing | fread ARCH ieee-be => OK
fopen ARCH ieee-le | fread ARCH ieee-be => OK
fopen ARCH ieee-be | fread ARCH ieee-be => OK
fopen ARCH       b | fread ARCH ieee-be => OK
fopen ARCH nothing | fread ARCH ieee-le => OK
fopen ARCH ieee-le | fread ARCH ieee-le => OK
fopen ARCH ieee-be | fread ARCH ieee-le => ERROR !
fopen ARCH       b | fread ARCH ieee-le => ERROR !
% MATLAB 2010b on Windows XP 32bits
>> test_arch_combinations()
fopen ARCH nothing | fread ARCH nothing => OK
fopen ARCH ieee-le | fread ARCH nothing => OK
fopen ARCH ieee-be | fread ARCH nothing => OK
fopen ARCH       b | fread ARCH nothing => OK
fopen ARCH nothing | fread ARCH  native => OK
fopen ARCH ieee-le | fread ARCH  native => OK
fopen ARCH ieee-be | fread ARCH  native => OK
fopen ARCH       b | fread ARCH  native => OK
fopen ARCH nothing | fread ARCH ieee-be => OK
fopen ARCH ieee-le | fread ARCH ieee-be => OK
fopen ARCH ieee-be | fread ARCH ieee-be => OK
fopen ARCH       b | fread ARCH ieee-be => OK
fopen ARCH nothing | fread ARCH ieee-le => OK
fopen ARCH ieee-le | fread ARCH ieee-le => OK
fopen ARCH ieee-be | fread ARCH ieee-le => OK
fopen ARCH       b | fread ARCH ieee-le => OK



Thus, it seems that the anomaly appears when the file is opened in ieee-be and
then the value is read in ieee-le .

On PC, no ARCH for fopen should be equivalent to ieee-le which doesn’t
result in error. Sorry for the mistake in the original post and thank you all
for your reactivity.

NOTE: On both my 64 and 32 bits PCs :

 >> native_float_format
ans = ieee-le



(file #34579)
    _______________________________________________________

Additional Item Attachment:

File name: test_arch_combinations.m       Size:2 KB


    _______________________________________________________

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]