MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica: how to set the format of binary numbers in plotting?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58626] Re: Mathematica: how to set the format of binary numbers in plotting?
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 10 Jul 2005 16:51:49 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, England
  • References: <daqp0r$6dp$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

1.156 wrote:
> I use BinaryReadList[filename, "Integer16"] to bring in an array of 
> numbers. I then do a bunch of operations on these numbers and then try 
> to plot them. They should be signed integers and interpreted in 2's 
> complement but apparently they have been converted to unsigned binary as 
> far as I can tell -- and the plots are horrible.
> 
> Can someone tell me how you can specify the interpretation (signed or 
> unsigned) of numbers before they are used in ListPlot[] ? Thanks.
> 
Hi 1.156 :-)

I do not think that the issue has anything to do with the plot command. 
Within Mathematica, the notions of signed, unsigned, long, double, char, 
etc. are irrelevant. The Mathematica language does not possess the 
notion of types, as you would find it in languages such as C, C++ or 
Java for instance, although it makes a clear distinction among exact, 
machine precision and arbitrary-precision arithmetic. To answer the last 
part of your question, you have no way of telling *ListPlot* that the 
numbers are signed or unsigned.

Having said that, I strongly suspect that the problem comes either from 
the data file you have imported (corrupted, not in the expected format) 
or that it was created on another hardware platform, such as a 
Macintosh, which uses a different byte ordering (the most significant 
bit can be stored first or at the end of the word, think about that as 
sorting the most significant bits in ascending or descending order, or 
from left to right or vice versa).

First you should check immediately after importing the data file that 
the numbers are what you have expected and/or change the bit ordering by 
using the option  ByteOrdering -> -$ByteOrdering. See the example in

http://documents.wolfram.com/mathematica/book/section-2.12.11

Hope this helps,
/J.M.


  • Prev by Date: Re: Complement replacement
  • Next by Date: Re: Re: Complement replacement
  • Previous by thread: Re: Mathematica: how to set the format of binary numbers in plotting?
  • Next by thread: NotationPalette with Ersek's SubscriptSymbols package