The HotDocs Computation Archive
Get Extra Help

0062 - "All (100%)"

Description:

Format a percentage as "all (100%)", "half (50%)", "five percent (5%)", etc.


• Code •

""
IF Percent-n = 100
   "all (100%)"
ELSE IF Percent-n = 75
   "three-fourths (75%)"
ELSE IF TRUNCATE( Percent-n, 0 ) = 66
   "two-thirds (66%)"
ELSE IF Percent-n = 50
   "one-half (50%)"
ELSE IF Percent-n = 25
   "one-fourth (25%)"
ELSE IF TRUNCATE( Percent-n, 0 ) = 33
   "one-third (33%)"
ELSE
   "«Percent-n:nine» percent («Percent-n»%)"
END IF

• Explanation •

This computation is a percentage formatter. It will spell out the common percentages in their fractional equivalents:

One-fourth (25%)
One-third (33%)
One-half (50%)
Two-thirds (66%)
Three-fourths (75%)
All (100%)

All other percentages are spelled out: forty percent (40%).

See also, Computation #0051: Format a Number as "nine point seven five", #0052: Format a Fraction as "four and one half", #0116: (Even) Smarter Fraction Formatting, #0150: Decimal Formatter.

 

• Model Template •

This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.

(Go to the download page)

 
 

• Contributors •

LegalCS