[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #47434] fwrite of integer types on Solaris wri
From: |
Mike Miller |
Subject: |
[Octave-bug-tracker] [bug #47434] fwrite of integer types on Solaris writes little-endian (should be big-endian) |
Date: |
Thu, 17 Mar 2016 01:11:16 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0 |
URL:
<http://savannah.gnu.org/bugs/?47434>
Summary: fwrite of integer types on Solaris writes
little-endian (should be big-endian)
Project: GNU Octave
Submitted by: mtmiller
Submitted on: Wed 16 Mar 2016 06:11:15 PM PDT
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: In Progress
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Solaris/SunOS
_______________________________________________________
Details:
Writing multi-byte integers using fwrite writes them in little-endian format
regardless of what ARCH parameter is given to fopen or fwrite. The default
should be big-endian, and that is what Octave thinks it is internally, but the
bytes are written in little-endian order.
Example:
>> nm = tempname; fid = fopen (nm, "wb"); fwrite (fid, 1, "int16"); fclose
(fid); system (sprintf ("od -tx1 %s", nm)); unlink (nm);
0000000 01 00
0000002
>> nm = tempname; fid = fopen (nm, "wb"); fwrite (fid, 1, "int32"); fclose
(fid); system (sprintf ("od -tx1 %s", nm)); unlink (nm);
0000000 01 00 00 00
0000004
>> nm = tempname; fid = fopen (nm, "wb"); fwrite (fid, 1, "int64"); fclose
(fid); system (sprintf ("od -tx1 %s", nm)); unlink (nm);
0000000 01 00 00 00 00 00 00 00
0000010
The results are the same if either fopen or fwrite are given any of the
possible ARCH values.
I've started looking into this but getting lost in the octave_stream::write
templates and data conversion options.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?47434>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #47434] fwrite of integer types on Solaris writes little-endian (should be big-endian),
Mike Miller <=