Re: Bug in ISHFT? (NOT) [message #39652] |
Mon, 31 May 2004 23:07 |
marc schellens[1]
Messages: 183 Registered: January 2000
|
Senior Member |
|
|
Craig Markwardt wrote:
> Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> writes:
>
>> Would anybody call this a bug in IDL?
>>
>> IDL> print, ishft(6UL,40UL)
>> 1536
>> IDL> print, ishft(6UL,8UL)
>> 1536
>>
>> ISHFT only seems to handle integers up to 32 bits, and then wraps
>> around.
>
>
> ... or rather, I had a bug in my brain. Somehow I was mixing up
> unsigned long and unsigned long64. My mistake.
I think there was a point in bringing it up:
At least its not really consistent:
IDL> print,ishft(1b,8)
0
IDL> print,ishft(1,16)
0
IDL> print,ishft(1L,32)
1
IDL> print,ishft(1LL,64)
1
One could think that for 8 and 16 bit there is no wrap-around, but for
32 and 64 there is.
But:
IDL> print,ishft(2ULL,63)
0
IDL> print,ishft(2ULL,64)
2
So for 32 and 64 bits, ISHFT divides the second paramter modulo
32 or 64 respectively before applying it, but not for 8 and 16 bit.
marc
|
|
|
Re: Bug in ISHFT? (NOT) [message #39657 is a reply to message #39652] |
Sun, 30 May 2004 21:06  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> writes:
> Would anybody call this a bug in IDL?
>
> IDL> print, ishft(6UL,40UL)
> 1536
> IDL> print, ishft(6UL,8UL)
> 1536
>
> ISHFT only seems to handle integers up to 32 bits, and then wraps
> around.
... or rather, I had a bug in my brain. Somehow I was mixing up
unsigned long and unsigned long64. My mistake.
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|