[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #41672] fread for "float" not matlab compatibl
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #41672] fread for "float" not matlab compatible |
Date: |
Sat, 26 Aug 2017 18:00:05 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #5, bug #41672 (project octave):
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:
if (s == "int8" || s == "integer*1")
retval = dt_int8;
else if (s == "uint8")
retval = dt_uint8;
else if (s == "int16" || s == "integer*2")
retval = dt_int16;
else if (s == "uint16")
retval = dt_uint16;
else if (s == "int32" || s == "integer*4")
retval = dt_int32;
else if (s == "uint32")
retval = dt_uint32;
else if (s == "int64" || s == "integer*8")
retval = dt_int64;
else if (s == "uint64")
retval = dt_uint64;
else if (s == "single" || s == "float32" || s == "real*4")
retval = dt_single;
else if (s == "double" || s == "float64" || s == "real*8")
retval = dt_double;
else if (s == "char" || s == "char*1")
retval = dt_char;
else if (s == "schar" || s == "signedchar")
retval = dt_schar;
else if (s == "uchar" || s == "unsignedchar")
retval = dt_uchar;
else if (s == "short")
GET_SIZED_INT_TYPE (short, );
else if (s == "ushort" || s == "unsignedshort")
GET_SIZED_INT_TYPE (unsigned short, u);
else if (s == "int")
GET_SIZED_INT_TYPE (int, );
else if (s == "uint" || s == "unsignedint")
GET_SIZED_INT_TYPE (unsigned int, u);
else if (s == "long")
GET_SIZED_INT_TYPE (long, );
else if (s == "ulong" || s == "unsignedlong")
GET_SIZED_INT_TYPE (unsigned long, u);
else if (s == "longlong")
GET_SIZED_INT_TYPE (long long, );
else if (s == "ulonglong" || s == "unsignedlonglong")
GET_SIZED_INT_TYPE (unsigned long long, u);
else if (s == "float")
{
if (sizeof (float) == sizeof (double))
retval = dt_double;
else
retval = dt_single;
}
else if (s == "logical")
retval = dt_logical;
else
(*current_liboctave_error_handler) ("invalid data type specified");
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.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?41672>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #41672] fread for "float" not matlab compatible,
Rik <=