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

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

[Octave-bug-tracker] [bug #54111] binary data read using "fread" doesn't


From: Rik
Subject: [Octave-bug-tracker] [bug #54111] binary data read using "fread" doesn't recognize any "PRECISION" arg in Windows 10
Date: Wed, 13 Jun 2018 12:46:44 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Update of bug #54111 (project octave):

                  Status:                    None => Invalid                
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #2:

I think Michael is correct in comment #1.  Try 'help fread' and note this
paragraph


The PRECISION argument may also specify a type conversion.  For
example, 'int16=>int32' causes 'fread' to read 16-bit integer
values and return an array of 32-bit integer values.  By default,
'fread' returns a double precision array.  The special form '*TYPE'
is shorthand for 'TYPE=>TYPE'.


Modifying your code to include the type conversion


octave:1> fidw=fopen("test.bin","w");
octave:2> fwrite(fidw,[100],"int8");
octave:3> fclose(fidw);
octave:4> fidr=fopen("test.bin","rb");
octave:5> val=fread(fidr,1,"int8=>int8")
val = 100
octave:6> fclose(fidr);
octave:7> whos val 
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  ===== 
        val         1x1                          1  int8

Total is 1 element using 1 byte



Marking as invalid and closing report.



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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