# [Pharo-project] [Slightly OT] Integers smarter than me today

Schwab,Wilhelm K bschwab at anest.ufl.edu
Wed Feb 17 16:07:26 EST 2010

```Thanks for bringing this up - yes,  David's(??) suggestion did the trick.  Beyond that, the key to figuring it out was making dot plots of the data stream so I could see the patterns.  There is still an unresolved question or two, but I appear to be getting data, and "the monkey on on their back" as a friend of mine would say.

Bill

-----Original Message-----
From: pharo-project-bounces at lists.gforge.inria.fr [mailto:pharo-project-bounces at lists.gforge.inria.fr] On Behalf Of Matthias Berth
Sent: Wednesday, February 17, 2010 3:42 PM
To: Pharo-project at lists.gforge.inria.fr
Subject: Re: [Pharo-project] [Slightly OT] Integers smarter than me today

I guess your problem is already solved, but I could not resist ;)

So you have 2^12 = 4096 possible 16 bit words? May I suggest a brute force solution? Make an Array with 2^16 entries to do the translation from 16 bit words to signed values like this:

signedValue := translationArray at: word

You can make a small script to fill the array. The advantage is that you can check the array's contents to see if you are doing the right thing. If your 2s complement theory should not work out then it is easy to change.

HTH

Matthias

On Thu, Feb 11, 2010 at 10:53 PM, Schwab,Wilhelm K <bschwab at anest.ufl.edu> wrote:
> Hello all,
>
> I am trying to make a recognizer for a communication protocol that has very likely been errantly documented.  Such tasks can be difficult enough with good docs, but I'm not even sure what is supposed to be happening, so it is really interesting.
>
> One of the things that I **think** is happening, is that 12-bit two's complement data is included at one point in the stream.  The bits are spread over a 16 bit word.  Let's assume that I can correctly gather the 12 bits together.  Could some kind soul suggest how to go from the resulting SmallInteger to the correct signed value?  Smalltalk is adding a wrinkle that I am not sure how to handle: should I set the "missing" bits to 1?  Out to bit 31?
>
> Any pointers/suggestions would be greatly appreciated.
>
> Bill
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
Pharo-project at lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

```