• 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: Crunch numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crunch numbers


  • Subject: Re: Crunch numbers
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 14 Mar 2002 23:22:59 +0000

Andy Wylie wrote on Thu, 14 Mar 2002 21:48:32 +1300:

>on 14/3/02 9:02 AM, Deivy Petrescu at email@hidden wrote:
>
>>(round (z * (10 ^ numdigits)) rounding as taught in school) * (10 ^
>numdigits)
>>div (10 ^ n) / (10 ^ numdigits)
>>
>no good system 8.6, any ideas?

(* Truncate n to d decimal places, with or without rounding. *)
on trnc from n onto d given rounding:rounding
tell 10 ^ d
tell n * it
if rounding then
it div 0.5 - it div 1
else
it div 1
end if
end tell
result / it -- ie. result / (10 ^ d)
end tell
end trnc

trnc from 123.456789 onto 1 with rounding
--> 123.5

NG
_______________________________________________
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: "tell" to a running process
  • Next by Date: Re: Getting the Documents Folder
  • Previous by thread: Re: Crunch numbers
  • Next by thread: Re: Crunch numbers
  • Index(es):
    • Date
    • Thread