Re: if statement / isinteger

From: Jatin Kala <J.Kala_at_nyahnyahspammersnyahnyah>
Date: Thu Jan 27 2011 - 20:38:50 MST

Use the floattointeger function ??



From: [] On
Behalf Of Paula Doubrawa Moreira
Sent: Friday, 28 January 2011 11:37 AM
To: Dennis Shea;
Subject: Re: if statement / isinteger


Sorry the do just entered in the email, I don't actually have it in the
script. My problem is that it's returning False, not True...


I want x to be always an odd whole number, so say x=12.3


xround = round(x,0) will be 12

a = xround/2 will be 6, except even though it's a whole
number, it's still not an integer, it's a "float" like x was originally.


So when I test with isinteger it gives me False and doesn't execute the
statement. Intuitively I though the number would "convert itself" to
integer if it was a whole number but of course it stays what it is. I
just wanted to add 1 if my number was even, because I only wanna work
with odds.


Any easier way to sort between odds/evens?




On Thu, Jan 27, 2011 at 6:23 PM, Dennis Shea <> wrote:

The function returns a logical value [True / False]

       function isinteger (
       return_val [1] : logical <====


if ( isinteger(a) ) then ; <<< This is if (True) then

end if

Why do you have "do a=a+1"
Where did that come from

On 1/27/11 8:13 PM, Paula Doubrawa Moreira wrote:

        Can anyone help me use if statements and logical structures
        how do I use the function "isinteger" with an if statement?
        I've tried:
        *if ( isinteger(a) ) then*
        *do a=a+1*
        *end if*
        *if ( isinteger(a) .eq. "True") then*
        *do a=a+1*
        *end if*
        I've tried moving things around in the if statement and even
though I
        know that a is an integer, it's not recognizing my if statement
        executing the command!
        *Paula Doubrawa Moreira*/
        /Graduate Student - Research Assistant
        International Arctic Research Center
        University of Alaska Fairbanks

        ncl-talk mailing list
        List instructions, subscriber options, unsubscribe:

Paula Doubrawa Moreira
Graduate Student - Research Assistant
International Arctic Research Center
University of Alaska Fairbanks

ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Thu Jan 27 20:38:59 2011

This archive was generated by hypermail 2.1.8 : Mon Jan 31 2011 - 10:38:24 MST