comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » 32-bit Unsigned Integers, Was: Unsigned Integers - How?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: 32-bit Unsigned Integers, Was: Unsigned Integers - How? [message #8199 is a reply to message #8110] Mon, 10 February 1997 00:00 Go to previous message
Peter Berdeklis is currently offline  Peter Berdeklis
Messages: 3
Registered: February 1997
Junior Member
On Sat, 8 Feb 1997, David Fanning wrote:
> Somehow, Peter, I just *knew* you didn't have 16-bit integers! :-)

Hard to believe that's cutting edge on a PC, isn't it? :-}

Thank you for your suggestion. It works perfectly. In return, here's
how to do it for an array.

th = '8f7b91dd'x ; Unsigned this is 2407240157.
; Signed this is -1887727139.

th_arr = replicate(th, 10) ; make an array of 10 of them to test

tb_arr = byte(th_arr, 0, 4, 10) ; map the array to a 4x10 array of bytes
; if the initial array is not 1D just add
; dimensions (up to 6 more)

; make your array of 10 doubles

td_arr = double(tb_arr(0,*)) + double(tb_arr(1,*)*2.^8) $
+ double(tb_arr(2,*)*2.^16) + double(tb_arr(3,*)*2.^24)


Of course, as you said, the byte order is dependent on the endian of the
machine. However, there is no need to check if the unsigned has
overflowed since this will correctly map values that haven't. Of course
if you do want to check, just check if the number is <0. It shouldn't be
if it is unsigned. :)

Thanks again for the help.

---------------
Peter Berdeklis
Dept. of Physics, Univ. of Toronto
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DICOM images: anyone written code to read them?
Next Topic: Re: Exceed with IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 06:29:47 PDT 2025

Total time taken to generate the page: 0.40033 seconds