help-octave
[Top][All Lists]
Advanced

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

Testing endianness


From: Jean-Francois Cardoso
Subject: Testing endianness
Date: Fri, 16 Jan 2004 11:59:48 +0100

Hello all,

I am porting some code from matlab to octave which needs to determine
the endianness of the machine, as shown below in the original matlab
version.  Some adjustments are needed because octave's computer() does
not return the same strings.  I could make these changes on an ad hoc
basis, adding new tests each time I want to run the code on a
different machine.  BUT, maybe someone knows of a clean way to test
for endianness.  Is there a simpler/more robust way to find out?

Could jwe think of adding a function (like isieee() for instance)
which would return the endianness of the machine?  I did not see
anything related.  That would be better than letting the user parse
strings.

Thanks, JFC

% First try to figure out if we need to swap bytes. 
%
friend = computer;
if     strmatch(friend,'PCWIN')    bswap = 'b';
elseif strmatch(friend,'LNX86')    bswap = 'b';
elseif strmatch(friend,'GLNX86')   bswap = 'b';
elseif strmatch(friend,'ALPHA')    bswap = 'b';
else   bswap = 'l';
end

=====



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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