Re: Int Function
Re: Int Function
- Subject: Re: Int Function
- From: Christopher Nebel <email@hidden>
- Date: Sun, 18 Aug 2002 20:35:59 -0700
On Sunday, August 18, 2002, at 07:36 PM, Paul Berkowitz wrote:
On 8/18/02 7:23 PM, "Christopher Nebel" <email@hidden> wrote:
Can anyone give me an easy way to get the Int of a number,
converting,
for instance, 6.1 into 6?
"round" from Standard Additions will do what you want.
Any particular reason why you favor an Addition over the native
AppleScript
div 1
which I sent in? If you repeating it hundreds - or thousands - of
times, div
1 will be much faster. Is it fragile in some way I don't know of?
I tend to prefer "round" because it makes the intent more clear, and
it's more flexible -- you can use different rounding modes without
adding a lot of code that doesn't come naturally to non-numerics folk.
(Consider how many times people here have asked how to round a number
to n decimal places.)
The speed vs. "div 1" isn't an issue to me because I'm not doing heavy
numerics work. To be perfectly honest, I don't trust truncation in
general because fixed-precision math produces strange results sometimes
(e.g., the infamous 2.32 * 100 div 1).
Aside from that, no, "div 1" isn't fragile, and it's certainly faster,
but I hope to correct that at some point, and not by gratuitously
slowing down "div". :)
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.