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

Home » Public Forums » archive » assign an octal number to a variable
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
assign an octal number to a variable [message #62885] Mon, 13 October 2008 15:40 Go to next message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
I found a method to assign an octal number to a variable.

For example,
a="30
print,a
It seems that the double quotation mark befroe the number can indicate
this number is octal value.
But I do not find its detailed directions in IDL help.

In the similar way, which symbol can indicate the binary and
hexadecimal number?


Best regards,
Du
Re: assign an octal number to a variable [message #62943 is a reply to message #62885] Tue, 14 October 2008 14:38 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
duxiyu@gmail.com writes:

> Finally, I find it in IDL help.
> It is under the topic "Defining and Using Constants".

Huh, amazing. Isn't that the page that comes up when you
search on "octal" in the on-line help? Wasted breath...

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: assign an octal number to a variable [message #62944 is a reply to message #62885] Tue, 14 October 2008 14:29 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
On Oct 14, 11:13 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Oct 14, 2:33 pm, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>> Yes, I know "16 is another notation of '16'o.
>> I want to learn more about it,
>> and wonder whether there is the similiar notation for the binary or
>> hexadecimal number.
>> But I cannot find any information about it in IDL help.
>> Did you see this notation before?
>
> Yes, this is the reason that you should never use double quotes for
> strings, because valid looking strings produce errors that take one
> forever to figure out why they are a syntax error:
>
>   IDL> print, "22 monkeys"
>
>   print, "22 monkeys"
>             ^
>   % Syntax error.
>
> As far as I know, there is no equivalent notation for binary or
> hexadecimal values, just the '100'b and 'FF'h notations.
>
> Mike
> --www.michaelgalloy.com
> Tech-X Corporation
> Software Developer II

Finally, I find it in IDL help.
It is under the topic "Defining and Using Constants".
Re: assign an octal number to a variable [message #62948 is a reply to message #62885] Tue, 14 October 2008 14:13 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Oct 14, 2:33 pm, "dux...@gmail.com" <dux...@gmail.com> wrote:
> Yes, I know "16 is another notation of '16'o.
> I want to learn more about it,
> and wonder whether there is the similiar notation for the binary or
> hexadecimal number.
> But I cannot find any information about it in IDL help.
> Did you see this notation before?

Yes, this is the reason that you should never use double quotes for
strings, because valid looking strings produce errors that take one
forever to figure out why they are a syntax error:

IDL> print, "22 monkeys"

print, "22 monkeys"
^
% Syntax error.

As far as I know, there is no equivalent notation for binary or
hexadecimal values, just the '100'b and 'FF'h notations.

Mike
--
www.michaelgalloy.com
Tech-X Corporation
Software Developer II
Re: assign an octal number to a variable [message #62951 is a reply to message #62885] Tue, 14 October 2008 13:33 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
On Oct 14, 9:46 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Oct 14, 12:09 pm, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>> Thank you very much.
>> This is what I want.
>
>> But I still have a question as follows:
>
>> IDL> print,"77
>>       63
>
>> "16 is equal to '77'o.
>
> I'm a bit confused by the statement. "16 is equal to '16'o and "77 is
> equal to '77'o; they are different notations for the same thing.
>
> ; 16 octal = 1 * 8 + 6 = 14 decimal
>
> IDL> print, "16
>       14
> IDL> print, '16'o
>       14
>
> ; 77 octal = 7 * 8 + 7 = 63 decimal
>
> IDL> print, "77
>       63
> IDL> print, '77'o
>       63

Yes, I know "16 is another notation of '16'o.
I want to learn more about it,
and wonder whether there is the similiar notation for the binary or
hexadecimal number.
But I cannot find any information about it in IDL help.
Did you see this notation before?
Re: assign an octal number to a variable [message #62954 is a reply to message #62885] Tue, 14 October 2008 12:46 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Oct 14, 12:09 pm, "dux...@gmail.com" <dux...@gmail.com> wrote:
> Thank you very much.
> This is what I want.
>
> But I still have a question as follows:
>
> IDL> print,"77
>       63
>
> "16 is equal to '77'o.

I'm a bit confused by the statement. "16 is equal to '16'o and "77 is
equal to '77'o; they are different notations for the same thing.

; 16 octal = 1 * 8 + 6 = 14 decimal

IDL> print, "16
14
IDL> print, '16'o
14

; 77 octal = 7 * 8 + 7 = 63 decimal

IDL> print, "77
63
IDL> print, '77'o
63
Re: assign an octal number to a variable [message #62956 is a reply to message #62885] Tue, 14 October 2008 11:09 Go to previous message
duxiyu@gmail.com is currently offline  duxiyu@gmail.com
Messages: 88
Registered: March 2007
Member
Thank you very much.
This is what I want.

But I still have a question as follows:

IDL> print,"77
63

"16 is equal to '77'o.
I do not find the explanation of this expression in IDL help.


Du


On Oct 14, 5:29 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Oct 14, 1:53 am, "dux...@gmail.com" <dux...@gmail.com> wrote:
>
>> I am looking for the method to assign a binary or hexadecimal  number
>> (such as 1101011 or 8AE3) to a variable.
>
> IDL> print, 'FF'x
>      255
> IDL> print, '100'b
>        4
> IDL> print, '77'o
>       63
>
> Mike
> --www.michaelgalloy.com
> Tech-X Corporation
> Software Developer II
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Casting boost::multi_array
Next Topic: Re: Is it possible to do overplot in xplot?

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

Current Time: Thu Oct 09 07:00:11 PDT 2025

Total time taken to generate the page: 0.56042 seconds