• 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: Same code gives different answers in 2 different scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Same code gives different answers in 2 different scripts


  • Subject: Re: Same code gives different answers in 2 different scripts
  • From: Chris Page <email@hidden>
  • Date: Wed, 03 Jun 2009 17:15:05 -0700

On Jun 2, 2009, at 7:33 PM, Shane Stanley wrote:

to findRound of num given numDecimals:n
   set x to 10 ^ n
   return (round (num * x)) / x
end findRound

set rounded_height to findRound of 3 given numDecimals:5
--> 3.0

What I'm really trying to say is that adding the ability to set a minimum or maximum number of decimals would make the round command a lot more useful.


findRound merely performs a calculation, with numDecimals indicating a maximum amount of precision. Formatting a string representation of a float with features like zero padding is a separate issue. If the OP intends to use findRound as part of formatted-string generation, the padding will have to be performed elsewhere, while producing a string representation of the result of findRound.

--
Chris Page

_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Same code gives different answers in 2 different scripts
      • From: Chris Page <email@hidden>
References: 
 >Re: Same code gives different answers in 2 different scripts (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Word Line Numbers
  • Next by Date: Re: Same code gives different answers in 2 different scripts
  • Previous by thread: Re: Same code gives different answers in 2 different scripts
  • Next by thread: Re: Same code gives different answers in 2 different scripts
  • Index(es):
    • Date
    • Thread