Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: Re: FLASH: Formatting Numbers, decimals
From: Helen Triolo
Date: Thu, 13 Jul 2000 14:27:28 +0100

Hi Branden. I think you missed the beginning of this thread, which was:
how would you format a number with commas marking the thousands,
millions, etc (eg, 32549325 -> 32,549,325). ( My attempt at answering
this is at http://i-technica.com/whitestuff/formatmillions.html )

The followup question was "and what if that number has a decimal?" (eg,
32593256.43254 -> 32,593,256.43254) So, a formatting problem rather
than a display-rounded problem, which is what I was trying to address
below. Your code suggestions welcome of course!

---------------------------------------------------
helen triolo � http://i-technica.com � 301-424-6037
Flash Q&A archive � http://i-technica.com/flashlist

Branden Hall wrote:
>
> The best way I have found is:
>
> say we have the number 23.12623
> and we want to reduce it down to 23.13
> first take the int of the number and subtract that from the actual number to
> get .12623
> then add .005 to that to get .13123
> then multiply that times 100 to get 13.123
> then take the int of that (13) and divide it by 100 to get .13
> then just add .13 to the int of the orginal number (23) to get 23.13
>
> jwoodw - Jeffrey Woodward wrote:
> >
> > I guess the only problem left with this issue is to take care of numbers
> > that happen to come out as decimals, i.e. - .54321 - Would you use some
> more
> > "If" statements to handle this scenerio?
>
> If the number might be a decimal (of unknown precision), I'd add another
> loop to scan the string from right to left until the decimal is found,
> and note where it appears (set a variable). Then modify the existing
> code to not put out any commas before the decimal is reached (and modify
> the line that checks for multiples of 3 to take into account the extra
> stuff to the right of the decimal). That's what I'd do but maybe
> there's an easier way -- if you come up with a good routine, post the
> code!
>

flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flashforward2000 and the Flash(tm) Film Festival
July 24-26, 2000, NEW YORK CITY, Hammerstein Ballroom
www.flashforward2000.com
Produced by United Digital Artists and lynda.com
Sponsored by Macromedia, Adobe Systems, Fusion, Inc, AtomFilms,
shockwave.com and Electric Rain.
1.877.4.FLASH.4 or (1.805.640.6679 outside the US and Canada)
Register before June 30 and save $200!!-- www.flashforward2000.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpatchinwag [dot] com


Replies
  RE: FLASH: Formatting Numbers, decimals, Branden Hall

[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]