Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8583

Reading Single and Double reals in Little-endian and Big-endian

From ezh <dgolber@aol.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Reading Single and Double reals in Little-endian and Big-endian
Date 2012-02-17 11:27 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jhldir$ot7$1@smc.vnet.net> (permalink)

Show all headers | View raw


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
correctly, using

numTriangles = ReadBinary[strm, Int32, ByteOrder ->
LeastSignificantByteFirst];

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
real number?

I'd hate to have to read up on the IEEE format and build the value
myself.

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_?

Thanks
Dave Golber

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Reading Single and Double reals in Little-endian and Big-endian ezh <dgolber@aol.com> - 2012-02-17 11:27 +0000
  Re: Reading Single and Double reals in Little-endian and Big-endian "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-20 07:54 +0000
    Re: Reading Single and Double reals in Little-endian and Big-endian ezh <dgolber@aol.com> - 2012-02-24 06:02 +0000
      Re: Reading Single and Double reals in Little-endian and Big-endian David Bailey <dave@removedbailey.co.uk> - 2012-02-25 06:55 +0000
    Re: Reading Single and Double reals in Little-endian and Big-endian "Oleksandr Rasputinov" <oleksandr_rasputinov@ymail.com> - 2012-02-26 09:21 +0000

csiph-web