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

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

[Octave-bug-tracker] [bug #63931] Binary fwrite writes incorrect data to


From: Dmitri A. Sergatskov
Subject: [Octave-bug-tracker] [bug #63931] Binary fwrite writes incorrect data to file
Date: Sun, 19 Mar 2023 14:22:44 -0400 (EDT)

Follow-up Comment #21, bug #63931 (project octave):

Yes. It is all the same bug...

>> clear all

fid = fopen ("m_eye.bin", "wb", "ieee-le");
matA = eye (100,150);
n = fwrite (fid, matA, "double");
fclose(fid);

assert (stat ("m_eye.bin").size == numel(matA) * 8)

fid = fopen ("m_rand.bin", "wb", "ieee-le");
matB = rand (100,150);
n = fwrite (fid, matB, "double");
fclose(fid);

assert (stat ("m_rand.bin").size == numel(matB) * 8)

fid = fopen ("m_eye.bin", "rb");
matC = fread (fid, inf, "double");
fclose(fid);

fid = fopen ("m_rand.bin", "rb");
matD = fread (fid, inf, "double");
fclose(fid);

assert (all (matC == matA(:)))
assert (all (matD == matB(:)))

clear ans fid
whos
error: assert (stat ("m_rand.bin").size == numel (matB) * 8) failed
error: called from
    assert at line 107 column 11
error: assert (all (matC == matA (:))) failed
error: called from
    assert at line 107 column 11
error: mx_el_eq: nonconformant arguments (op1 is 14378x1, op2 is 15000x1)
Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         matA      100x150                      800  double
         matB      100x150                   120000  double
         matC    15000x1                     120000  double
         matD    14378x1                     115024  double
         n           1x1                          8  double

Total is 59379 elements using 355832 bytes



Dmitri.
-- 



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63931>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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