assign an octal number to a variable [message #62885] |
Mon, 13 October 2008 15:40  |
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 #62944 is a reply to message #62885] |
Tue, 14 October 2008 14:29  |
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  |
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  |
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  |
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  |
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
|
|
|