Reading Single and Double reals in Little-endian and Big-endian
- To: mathgroup at smc.vnet.net
- Subject: [mg125003] Reading Single and Double reals in Little-endian and Big-endian
- From: ezh <dgolber at aol.com>
- Date: Fri, 17 Feb 2012 06:25:18 -0500 (EST)
- Delivered-to: email@example.com
I am running Mathematica 4 on a PC.
I am reading a file (an STL file), which has 32-bit integers and 32-
bit reals in little-endian format. I can read in the integers
numTriangles = ReadBinary[strm, Int32, ByteOrder ->
However, the documentation states (and is correct) that ByteOrder ->
LeastSignificantByteFirst only affects reading integers. So far, I
have not figured out how to read 32-bit reals ("Single") correctly.
I could read in the 32-bits as bytes, and reverse the order, and build
a 32-bit integer with the correct bits in it to be the desired 32-bit
real. But how do I get Mathematica to regard those 32-bits as an IEEE
I'd hate to have to read up on the IEEE format and build the value
I can't be the first person in theworld to hit this problem!
And why (futile question) doesn't mathematica know about big- and
little-endian for _reals_ as well as for _integers_?
Prev by Date:
Controlling # Processors Used by MathKernel?
Next by Date:
NDSolve slow when using generic function definition
Previous by thread:
Re: Controlling # Processors Used by MathKernel?
Next by thread:
Re: Reading Single and Double reals in Little-endian and Big-endian