Re: histogram and UINT [message #70124] |
Thu, 18 March 2010 09:32 |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 3/17/10 5:58 PM, Kenneth P. Bowman wrote:
> In article<hnrj7g$hqh$1@speranza.aioe.org>,
> mgalloy<mgalloy@gmail.com> wrote:
>
>> On 3/17/10 12:36 PM, Kenneth P. Bowman wrote:
> Hmm.
>
> This part of the docs
>
> IDL Programmer's Guides - Defining and Using Constants - Integer Constants
>
> implies that U and US are identical.
>
> OTOH, the table in the DEFINT section implies that the constant 42U does not
> include a type specifier.
>
> Huh?
>
> There may be a good reason for this syntactical subtlety (aka "a really
> obscure feature"), but ITTVIS REALLY needs to make this clearer in the docs.
I think the docs just need to be cleaned up a bit. Clearly, "u" should
modify the specified type (and the default integer type if no type is
specified) just like "x" or "o" modify the base of the specified type.
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: histogram and UINT [message #70125 is a reply to message #70124] |
Wed, 17 March 2010 16:58  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <hnrj7g$hqh$1@speranza.aioe.org>,
mgalloy <mgalloy@gmail.com> wrote:
> On 3/17/10 12:36 PM, Kenneth P. Bowman wrote:
>> I did notice that with IDL 7.1.1 on Mac OS X, using the U suffix
>> creates a ULONG, not a UINT. This clearly contradicts the documentation.
>>
>> IDL> help, 65U, 65US
>> <Expression> ULONG = 65
>> <Expression> UINT = 65
>>
>> You have to use US to create a UINT.
>>
>> Ken Bowman
>
> That is not what I get:
>
> IDL> help, 65u
> <Expression> UINT = 65
>
> Do you have "compile_opt defint32" in a startup file?
>
> Mike
Hmm.
This part of the docs
IDL Programmer's Guides - Defining and Using Constants - Integer Constants
implies that U and US are identical.
OTOH, the table in the DEFINT section implies that the constant 42U does not
include a type specifier.
Huh?
There may be a good reason for this syntactical subtlety (aka "a really
obscure feature"), but ITTVIS REALLY needs to make this clearer in the docs.
Ken
|
|
|
Re: histogram and UINT [message #70126 is a reply to message #70125] |
Wed, 17 March 2010 14:57  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 3/17/10 12:36 PM, Kenneth P. Bowman wrote:
> I did notice that with IDL 7.1.1 on Mac OS X, using the U suffix
> creates a ULONG, not a UINT. This clearly contradicts the documentation.
>
> IDL> help, 65U, 65US
> <Expression> ULONG = 65
> <Expression> UINT = 65
>
> You have to use US to create a UINT.
>
> Ken Bowman
That is not what I get:
IDL> help, 65u
<Expression> UINT = 65
Do you have "compile_opt defint32" in a startup file?
Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
|
|
|
Re: histogram and UINT [message #70127 is a reply to message #70126] |
Wed, 17 March 2010 11:36  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article
<ab4b613a-31e0-48ab-9472-6c840fb0fafa@o30g2000yqb.googlegroups.com>,
Jeremy Bailin <astroconst@gmail.com> wrote:
> I've discovered an interesting "feature" in histogram... I'm sure it's
> the expected behaviour, but in this case it had a consequence that
> bit me.
>
> I have some unsigned integer input data that I want to histogram. I'm
> looking at things right around the saturation level, so most of the
> data is exactly 65535, but I also want a bin past that. The following
> works:
>
> h = histogram(data, min=65500ul, max=65535ul)
>
> But the following doesn't:
>
> h = histogram(data, min=65500ul, max=65536ul)
> % HISTOGRAM: Illegal binsize or max/min.
>
> What seems to be happening is that the min/max values are cast into
> the same data type as data, in this case giving a nonsensical max of
> 0u. To do what I want, I need to cast data into a ULONG in this
> histogram call... or use max=65535u and append an appropriate number
> of 0s onto h.
>
> -Jeremy.
It seems logical to me that HISTOGRAM would take type information
from the input variable, not the keywords. (The keywords are optional.)
And since integer arithmetic 'wraps around'
IDL> print, 65535US + 1US
0
the result is to be expected.
I did notice that with IDL 7.1.1 on Mac OS X, using the U suffix
creates a ULONG, not a UINT. This clearly contradicts the documentation.
IDL> help, 65U, 65US
<Expression> ULONG = 65
<Expression> UINT = 65
You have to use US to create a UINT.
Ken Bowman
|
|
|