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

Home » Public Forums » archive » Wrong documentation for BitGet()?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Wrong documentation for BitGet()? [message #93162] Tue, 03 May 2016 10:34 Go to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
Hello,

I was reading the help on the BitGet method,

https://www.harrisgeospatial.com/docs/idl_integer.html#BitGe t

And it seems there is a typo. It says

Print the 3rd bit value of each element of an array:
num = INDGEN(8)
PRINT, num.BitGet( 3 )
IDL prints:
0 0 0 0 1 1 1 1

My experimenting indicates the argument of BitGet is the bit number, starting from zero, not from one as the help indicates. To get the 3rd bit, and obtain the result shown in the example, it seems it should be num.BitGet(2).

Is this correct or am I missing something?

Paulo
Re: Wrong documentation for BitGet()? [message #93163 is a reply to message #93162] Tue, 03 May 2016 11:05 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Yes, it looks like the documentation might be been written before the IDL code was written ;-)

The situation is even worse for the .bitset method. Again, the documentation says that the bit position is 1-based whereas it is actually 0-based. But the documentation is also incorrect about how a vector of positions is applied.
The example is

IDL> num = [0, 0, 0, 0]
IDL> PRINT, num.BitSet([1, 2, 3, 4])
1 2 4 8

whereas what IDL actually displays is
30 30 30 30

The position vector applies to *every* element of the input array, setting them all to 2^1 + 2^2 + 2^3 + 2^4 = 30

--Wayne

On Tuesday, May 3, 2016 at 1:34:02 PM UTC-4, Paulo Penteado wrote:
> Hello,
>
> I was reading the help on the BitGet method,
>
> https://www.harrisgeospatial.com/docs/idl_integer.html#BitGe t
>
> And it seems there is a typo. It says
>
> Print the 3rd bit value of each element of an array:
> num = INDGEN(8)
> PRINT, num.BitGet( 3 )
> IDL prints:
> 0 0 0 0 1 1 1 1
>
> My experimenting indicates the argument of BitGet is the bit number, starting from zero, not from one as the help indicates. To get the 3rd bit, and obtain the result shown in the example, it seems it should be num.BitGet(2).
>
> Is this correct or am I missing something?
>
> Paulo
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: syntax for calling parent class _overloadPlus method
Next Topic: Visualize a Radar image with ENVI

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

Current Time: Wed Oct 08 09:13:52 PDT 2025

Total time taken to generate the page: 0.00420 seconds