• 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: how to format decimal precision of a real?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to format decimal precision of a real?


  • Subject: Re: how to format decimal precision of a real?
  • From: Kai Edwards <email@hidden>
  • Date: Sun, 03 Mar 2002 06:15:12 +0000

on Sat, 02 Mar 2002 17:30:27 -0800, Bill Hoffman <email@hidden> wrote:

> I can't believe I don't know (and can't find anywhere) the answer to
> this but...
>
> How do I format:
>
> a real -- 324.234234234
> as -- 324.23
>
> (or to any specified number of digits after the decimal).
>
> Is there something straightforward that I'm somehow not getting, or is
> it one of those issues where I'll have to futz around with coercing it
> to a string, setting text delimiters to split on the decimal, counting
> the chars in remainder, yada yada....sheesh. If so I can figure that
> out, but I'm hoping there's an AS equivalent of 'format' that has
> somehow escaped me. I suspect not.

Bill, this is just off the top of my head, and I haven't tested it
exhaustively - but it might be a starting point...

rnd(324.234234234, 2)

to rnd(num, decPlaces)
set e to 10 ^ decPlaces
num * e div e + num * e mod e div 1 / e
end rnd

HTH

Kai

--

**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************
_______________________________________________
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: how to format decimal precision of a real?
      • From: Bill Hoffman <email@hidden>
  • Prev by Date: can' t set path of original of alias file?
  • Next by Date: Re: how to format decimal precision of a real?
  • Previous by thread: Re: how to format decimal precision of a real?
  • Next by thread: Re: how to format decimal precision of a real?
  • Index(es):
    • Date
    • Thread