• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Taking into account negative numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: AppleScript 1.8.3 Available for Mc OS 9 and X
  • Next by Date: Re: AppleScript 1.8.3 Available for Mc OS 9 and X
  • Previous by thread: Re: Taking into account negative numbers
  • Next by thread: Applet problem with AS 1.8.3
  • Index(es):
    • Date
    • Thread