Skip to content

Percentages & Proportions

Percentages in ordinary calculators are notoriously confusing. Standard calculators lack semantic context—pressing 100 + 10% on a pocket calculator might produce 100.1 instead of 110.

Kalc features a dedicated Percentage Engine with distinct AST node representations for direct scaling, additive markups, subtractive discounts, relative changes, and reverse percentage equations.


The 7 Core Percentage Patterns

PatternExample SyntaxMathematical MeaningEvaluates To
1. Direct Value20% of $150$\text{Base} \times (P / 100)$$30.00
2. Additive Markup$50 + 10% or 10% on $50$\text{Base} \times (1 + P / 100)$$55.00
3. Subtractive Discount$80 - 15% or 15% off $80$\text{Base} \times (1 - P / 100)$$68.00
4. Relative Change$50 to $75 as %$((B - A) / A) \times 100$50%
5. Proportional Ratio$50 as a % of $200$(A / B) \times 100$25%
6. Proportional Markup$70 as a % on $20$((A - B) / B) \times 100$250%
7. Proportional Discount$20 as a % off $80$((B - A) / B) \times 100$75%

1. Direct Percentage (P% of Base)

Calculates the exact fraction of a number, currency, or physical dimension:

text
15% of $80                                      // $12.00
8.5% of $3,400                                  // $289.00
25% of 120 km                                   // 30 km
33% of 2 hours in mins                          // 39.6 min

2. Additive Percentages (Base + P% / P% on Base)

Adds a percentage to a base value. Kalc recognizes descriptive words like tip, tax, sales tax, markup, or bonus:

text
dinner = $75 + 20% tip                          // $90.00
subtotal $3,400 + 8.25% sales tax               // $3,680.50
10% on $500                                     // $550.00
Wholesale $450 + 40% markup                     // $630.00
salary $120,000 + 15% bonus                     // $138,000.00

3. Subtractive Percentages (Base - P% / P% off Base)

Reduces a value by a specified percentage. Accepts descriptive terms like discount or off:

text
MSRP = $1,200 - 15% discount                    // $1,020.00
20% off $80                                     // $64.00
portfolio $500k - 8% market drawdown            // $460,000.00
Weight 85 kg - 5% in kg                         // 80.75 kg

4. Relative Change (A to B as %)

Calculates the rate of growth or reduction between two values:

text
50 to 90 as %                                   // 80%
100 to 80 as %                                  // -20%
$42k to $48.3k as %                             // 15%
line1 to line2 as %                             // Computes relative growth across lines

5. Proportions & Ratios (as a % of / on / off)

A as a % of B

Calculates direct proportional share:

text
$50 as a % of $200                              // 25%
Rent $2,400 as a % of Income $6,000             // 40%
35 min as a % of 1 hour                         // 58.33%

A as a % on B

Calculates the markup of $A$ relative to cost $B$:

text
$70 as a % on $20                               // 250%
Selling $35 as a % on Cost $10                  // 250%

A as a % off B

Calculates the effective discount of $A$ relative to original price $B$:

text
$20 as a % off $70                              // 71.43%
Sale $120 as a % off Original $200              // 40%

6. Reverse Percentage Equations

When budgeting or auditing invoices, you often know the final amount and need to calculate the pre-tax, pre-discount, or pre-fee origin.

Kalc solves these automatically using natural language:

P% of what is Target

Solves the initial base before a direct percentage was applied:

text
5% of what is 6 EUR                             // 120.00 EUR
Agent fee 6% of what is $24,000                 // $400,000.00 (Property price)
Seed round 15% of what is $750k                 // $5,000,000.00 (Company valuation)

P% on what is Target

Solves the original net price before sales tax or markup:

text
10% on what is $110                             // $100.00
8.5% on what is $1,085                          // $1,000.00
19% VAT on what is 1,428 EUR                    // 1,200.00 EUR (Pre-tax subtotal)

P% off what is Target

Solves the original full sticker price before a discount was taken:

text
20% off what is $80                             // $100.00
40% off what is sale tag $144                   // $240.00 (Original MSRP)
15% rebate off what is $34,000                  // $40,000.00

Native macOS Computational Notepad • Pure Swift with Strict Concurrency