IDL Exercise 1

The purpose of this exercise is to become familiar with the data types used in IDL and with basic operators and expressions. We will make use of the operators +, -, * and /, which represent addition, subtraction, multiplication and division. These operators will be used only with numbers and variables that represent numbers, but the scope of their use will be expanded significantly as we go on in the course. For this exercise their operation should be what you would expect.
 
  1. Open the IDL development environment. If you are using a Unix X-Windows system, type IDLDE at the command prompt. If you are using another platform, start IDL as described for that system.

  2.  
  3. The IDL procedure help will be used to display information about IDL variables and the IDL environment. If you want to know the type and value of a variable, A, you can type the statement
  4. IDL> help,A

    Type the following lines at the IDL command prompt (IDL>):

    k=5
    help,k

    What information is available?

  5. We will now construct variables of various types. These will be used in a later step to construct expressions. Type each of the commands at the IDL command prompt.
  6. a=3.5
    b=12L
    c=34B
    d='25'X
    e='25'O
    f=25

    Find the data type of each variable by using the help statement. Information about octal and hexadecimal constants is given at this link as well as in the IDL help pages on constants. You should be able to explain why d, e and f have different integer values.
     

  7. Type the following commands at the IDL command prompt. The ampersand & is used to allow multiple statements to be entered on the same line. IDL treats & as a separator between statements. You should be able to explain both the numerical result and the data type for each statement.

    u=3*k+4 & help,u
    v=3*k+4. & help,v
    w=b+c & help,w
    x=10*c & help,x
    y=d+e+f & help,y
    z=a*e+b & help,z


  8. Type the following commands at the IDL command prompt. The ampersand & is used to allow multiple statements to be entered on the same line. IDL treats & as a separator between statements. You should be able to explain both the numerical result and the data type for each statement.

    p=k/2 & help,p
    q=3*k/2 & help,q
    r=3*(k/2) & help,r
    s=(3+4)/5 & help,s
    t=3/5+4/5 & help,t
    t2=3/5+4/5. & help,t2
    t3=(3+4)/5. & help,t3