Re: Taking into account negative numbers
Re: Taking into account negative numbers
- Subject: Re: Taking into account negative numbers
- From: "Arthur J. Knapp" <email@hidden>
- Date: Tue, 25 Jun 2002 15:58:01 -0400
>
Date: 25 Jun 2002 07:04:03 -0400
>
Subject: Taking into account negative numbers
>
From: "Anthony Adachi" <email@hidden>
>
Does anybody know what's the best way to check to see whether a number is
>
negative?
on IsNegative(n)
return (n < 0)
end
>
More specifically, I'm trying to figure out the best way to check whether
>
the difference between two real numbers falls outside of a certain degree
>
of tolerance.
on AbsDif(x, y)
tell (x - y) to if (it < 0) then
return -it
else
return it
end if
end AbsDif
And just for the fun of it:
on Abs(n) -- version 1
if (n < 0) then
return -n
else
return n
end
end
on Abs(n) -- version 2, "inline"
return (n * n) ^ 0.5 --> value will be of class real
end
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.