• 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
rounding integers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rounding integers


  • Subject: rounding integers
  • From: Chet Goetz <email@hidden>
  • Date: Fri, 31 Oct 2003 10:08:01 -0600

Please forgive me if this has been discussed (I haven't been able to find it so far)

I'm making a script that takes a price ($) and multiplies it by 3 percentages and then lists the discounted prices (*.94, *.75, and *.56). (We give quantity discounts on some parts, but not all.)

I'd like the user to be able to input a price in a dialog box (no problems there) and then get back a dialog that has the discounted prices (no problems there, either). However, I get numbers that need to be rounded to the hundredth place (19.95 instead of 19.948). I've read about how to round up/down/toward zero/as taught in school, but that seems to get rid of the decimals entirely.

Would someone be able to get me started on how to round a number to two decimals?

--------------
[Here's what I have so far:]
set temp to display dialog "Original Price?" default answer "14.58"
set temp to text returned of temp as number

set _1_5 to temp
set _6_20 to (temp * 0.94)
set _21_50 to (temp * 0.75)
set _51_up to (temp * 0.56)

display dialog "Price Breaks by Quantity" & return & "Qty. 1-5: $" & _1_5 & return & "Qty. 6-20: $" & _6_20 & return & "Qty. 21-50: $" & _21_50 & return & "Qty. 51+: $" & _51_up
--------------

Thanks!

Chet Goetz
_______________________________________________
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.

  • Follow-Ups:
    • Re: rounding integers
      • From: Pat Cannon <email@hidden>
    • Re: rounding integers
      • From: Donald Goyette <email@hidden>
    • Re: rounding integers
      • From: Steve Mills <email@hidden>
  • Prev by Date: Creating a line in Illustrator
  • Next by Date: Re: rounding integers
  • Previous by thread: Creating a line in Illustrator
  • Next by thread: Re: rounding integers
  • Index(es):
    • Date
    • Thread