Re: 32-bit Unsigned Integers, Was: Unsigned Integers - How? [message #8108] |
Sun, 09 February 1997 00:00 |
brian.jackel
Messages: 23 Registered: May 1996
|
Junior Member |
|
|
In article <davidf-ya023080000802971828060001@news.frii.com> davidf@dfanning.com (David Fanning) writes:
> Peter Berdeklis <peter@atmosp.physics.utoronto.ca> carries on this
> discussion about 16-bit unsigned integers when he writes:
>> Unfortunately, I'm not reading 16-bit integers but 32-bit integers.
>> Sorry I forgot to mention that. So how would I pull the same trick
>> with 32-bit integers?
> Somehow, Peter, I just *knew* you didn't have 16-bit integers! :-)
Yes, that would be too easy, wouldn't it :)
Well, since it's Sunday, and I really should be writing my thesis, here's my
shot at it:
IDL> highbit= 2.0d0^31
IDL> newvalue= DOUBLE(value AND '7FFFFFFF'XL) + highbit*(value LT 0L)
which appears to do the trick on my PC and our Alpha box. I think it
should work in general, so long as IDL always puts the sign in the upper
bit. Anybody know if this is actually true? Loss of precision shouldn't
be an issue with this, as Doubles are 64 bits, so a 32 bit Long should
fit in with plenty room to spare for the exponent.
So, can anyone
a) see a problem with this and/or
b) make it faster?
waiting in anticipation (or is that procrastination?)
Brian Jackel
University of Western Ontario
|
|
|