AnsweredAssumed Answered

Re-2: vrf vrf digest: October 29, 2005

Question asked by g.nied on Nov 1, 2005
The data I'm dealing with is all unsigned when it comes off the wire, so I
assume there are no negatives to deal with there.

Thanks for the warning, should I ever reuse that code.

--
Graeme Hilton
R&D Engineer

Schlumberger Sensa

Bill Ossmann wrote the following on 02/11/2005 16:25:
> I don't know if you have to deal with negative numbers, but if you do I
> think that formula will cause an integer overflow for an int16, or not give
> the expected 2's complement as an int32.
> --
> Bill Ossmann
> Philips Ultrasound
> e-mail:  bill.ossmann@philips.com
>
> Graeme Hilton <GHilton@slb.com> wrote on 11/02/2005 10:00:12 AM:
>
>> Thanks Dave,
>>
>> I had to fiddle a little to get this to accept my data, but it works
> well.
>> However, I persevered a little more with the socket reading and came
>> up with this:
>>
>>  From Socket, READ BINARY x BYTE ARRAY:16001,2
>> Then a formula: (x[*,1]*256+x[*,0]) to marry the two columns of
>> bytes together.
>>
>> Very quick and very simple.
>>
>> --
>> Graeme Hilton
>> R&D Engineer
>>
>> Schlumberger Sensa
>>
>>
>> David Watling wrote the following on 02/11/2005 14:08:
>>> Hi Graeme,
>>> I wrote a byteswop formula which works on all elements of the array at
>>> once.  Load the array as INT16, then run the swopper function.  You may
>>> or may not want the 2's cmpl function as well.
>>>
>>> Function byteswop int16:
>>> bitOr(bitAnd(bitShift(A,-8),#H00ff),bitAnd(bitShift(A,8),#Hff00));
>>>
>>> 2's cmpl
>>> asInt16(A-(A DIV 32768)*65536);
>>>
>>>
>>> Regards
>>>
>>> David Watling
>>>
>>> -----Original Message-----
>>> From: Graeme Hilton [mailto:GHilton@slb.com]
>>> Sent: 02 November 2005 13:43
>>> To: VRF
>>> Subject: [vrf] Array of bytes convert to array of int16s
>>>
>>> Hi All,
>>>
>>> Here's my latest puzzle;
>>>
>>> I am reading data from a TCP/IP socket.  I read 32002 bytes which
>>> represent
>>> 16001 16-bit integers.  I can't use the READ BINARY x INT16 ARRAY1D
>>> 16001 as the
>>> data is presented as LSB first whereas the To/From Socket object
> assumes
>>> it's
>>> MSB first.
>>>
>>> To stitch these numbers together I run through the following:
>>> For Each (A[2*i]+A[(2*i)+1]*256) and collect the results to create my
>>> int16
>>> array of 16001 elements.
>>>
>>> My problem is that this takes a significant amount of time (compared to
>>> the rest
>>>   of the program).  Does anyone have a non-looping way of doing this or
>>> another
>>> time-saving method?
>>>
>> ---
>> You are currently subscribed to vrf as: bill.ossmann@philips.com
>> To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
>> To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
>> To send messages to this mailing list,  email "vrf@agilent.com".
>> If you need help with the mailing list send a message to "owner-
>> vrf@it.lists.it.agilent.com".
>> Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".
>
>
> ---
> You are currently subscribed to vrf as: GHilton@slb.com
> To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
> To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
> To send messages to this mailing list,  email "vrf@agilent.com". 
> If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
> Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".
>

---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "www.oswegosw.com/vrf_archive/".

Outcomes