Re: assign an octal number to a variable [message #62879] |
Tue, 14 October 2008 00:53  |
duxiyu@gmail.com
Messages: 88 Registered: March 2007
|
Member |
|
|
The function in the page is designed to express a decimal number in a
binary or hexadecimal representation.
However, the function I want is to assign a binary or hexadecimal
number to a variable.
For example, the expression (A="30) means that assign the octal number
30 to A.
If you print it in the decimal representation, it will give the result
24.
I am looking for the method to assign a binary or hexadecimal number
(such as 1101011 or 8AE3) to a variable.
Best regards,
Du
On Oct 14, 1:09 am, David Fanning <n...@dfanning.com> wrote:
> dux...@gmail.com writes:
>> 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?
>
> I hate to mention it, but I spent quite a bit of time putting
> a search engine on Coyote's Guide to IDL Programming for just
> this purpose. :-)
>
> http://www.dfanning.com/misc_tips/binary_hex.html
>
> If you want to see where octal (and hexadecimal) numbers
> are defined, something like "octal" in the on-line help
> index works pretty well.
>
> 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 #62966 is a reply to message #62879] |
Tue, 14 October 2008 08:29  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
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
|
|
|