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: Wed, 15 Mar 2023 21:38:56 -0400 (EDT)

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

Here is modified test script:


$ cat t1.m 
for ii = 1:3
  val = uint8(126+ii)   
  n = 1; 
  a = ones(n,1)*val;
  f = fopen('a.a','wb');
  cw = fwrite(f,a,'uint8')
  fclose(f);

  f = fopen('a.a','rb');
  [b, cr] = fread(f,n,'uint8');
  fclose(f);

  cr1 = cr
  x = a(1)
  y = b(1)
endfor



Running it:


>> clear
>> whos
>> t1
val = 127
cw = 1
cr1 = 1
x = 127
y = 127
val = 128
cw = 1
cr1 = 1
x = 128
y = 63
val = 129
cw = 1
cr1 = 1
x = 129
y = 63
>>



od -d a.a 
0000000    63
0000001


So some kind of unsigned/signed int mixed up?

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]