bugGNU Octave - Bugs: bug #41672, fread for "float" not...


bug #41672: fread for "float" not matlab compatible

Submitted by:  Rik <rik5>
Submitted on:  Sat 22 Feb 2014 09:58:20 PM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Thu 31 Aug 2017 10:48:41 PM UTC, comment #6:

I made Octave compatible with Matlab both in action and in documentation in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/3706091dc91c). Marking as Fixed and closing report.

Rik <rik5>
Project Administrator
Sat 26 Aug 2017 10:00:04 PM UTC, comment #5:

I changed the documentation to show that "float" is not system-dependent, but actually 32 bits (http://hg.savannah.gnu.org/hgweb/octave/rev/58435a400d4e).

The Matlab documentation for fread (http://www.mathworks.com/help/matlab/ref/fread.html) has a table with all of the sizes in bits and bytes for each type. These are not platform dependent. Should the function "oct_data_conv::string_to_data_type (const std::string& str)" in liboctave/util/data-conv.cc be re-written?

Here is an excerpt:

Given that the sizes are fixed, it seems like "schar", for example, should return dt_int8 rather than dt_schar.

This would also be the place to change unsigned long to return 32 bits.

Rik <rik5>
Project Administrator
Wed 19 Mar 2014 06:46:48 PM UTC, comment #4:

> Does Matlab really always force long to be 32 bits, even on 64-bit Linux systems?

Yes, it does.

On 64-bit Windows R2011a and 64-bit Linux R2010a:

Philipp Kutin <pkutin>
Mon 10 Mar 2014 04:38:36 AM UTC, comment #3:

This seems to be the case, the docs for fread/fwrite don't seem to distinguish between platform types.

Someone could verify by running the following in Matlab on 64-bit Windows:

In 64-bit Octave, arr is a one-element array of -1, but in 64-bit Matlab it may be a two-element array of -1.

Mike Miller <mtmiller>
Project Administrator
Sun 23 Feb 2014 07:09:43 PM UTC, comment #2:

I suspect that Matlab dropped the system-dependence of the float at some point. We can too.

As for integer types, I think it is pretty much universal now that short is 16 bits and int is 32 bits and on 32-bit systems, long is also 32 bits. But on 64-bit systems, long is 64 bits on Linux systems and still 32 bits on Windows systems. Does Matlab really always force long to be 32 bits, even on 64-bit Linux systems? If so, I guess we have to do the same or I'm sure we'll eventually get complaints about that difference.

John W. Eaton <jwe>
Project Administrator
Sun 23 Feb 2014 06:33:17 PM UTC, comment #1:

I think we've eliminated support for all non-IEEE floating point types now, so float will always be 32 bits. But that could be made more explicit to be Matlab compatible. I think the integer types are more troublesome, if we want Matlab compatibility we should get rid of all platform-dependence for the type names, right?

Mike Miller <mtmiller>
Project Administrator
Sat 22 Feb 2014 09:58:20 PM UTC, original submission:

This may just be a documentation issue. According to Matlab's documentation for fread (http://www.mathworks.com/help/matlab/ref/fread.html), the 'float' type should always be 32 bits. Octave's documentation states that the 'float' type is platform dependent. In fact this difference occurs for all the types which are not strictly defined by a standard (so short, long, etc.).

I don't if Octave is actually doing what it is saying it does, or whether it too just assumes float is 32 bits always.

Rik <rik5>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by pkutin (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    Thu 31 Aug 2017 10:48:41 PM UTC rik5 StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    Thu 27 Mar 2014 02:45:16 AM UTC mtmiller CategoryNone => Octave Function
        StatusNeed Info => Confirmed
    Mon 10 Mar 2014 04:38:36 AM UTC mtmiller StatusNone => Need Info

    Back to the top

    Powered by Savane 3.3