Home Renovation
Kitchen remodel and patio budget using averages, square roots, constants, booleans, and rate conversions.
Planning a kitchen remodel and backyard patio is a great way to see CalcMark’s math functions, constants, boolean logic, and rate conversions working together in one document.
The complete CalcMark file is available at testdata/examples/home-renovation.cm.
Averaging Contractor Quotes #
You’ve collected three quotes for the kitchen remodel. The avg function takes any number of values and returns their mean:
quote_a = 8500
quote_b = 9200
quote_c = 7800
average_quote = average of quote_a, quote_b, quote_c| quote_a = 8500 | → | 8.5K |
| quote_b = 9200 | → | 9.2K |
| quote_c = 7800 | → | 7.8K |
| average_quote = average of quote_a, quote_b, quote_c | → | 8.5K |
The average comes out to 8,500. The average of syntax is the natural language form — you can also write avg(quote_a, quote_b, quote_c) using function-call syntax.
CalcMark features: average of (NL form of avg()); variable references.
Room Measurements with sqrt
#
You need the kitchen diagonal for countertop layout planning. CalcMark’s sqrt function handles the Pythagorean theorem:
kitchen_length = 15
kitchen_width = 12
kitchen_sqft = kitchen_length * kitchen_width
diagonal = sqrt(kitchen_length ^ 2 + kitchen_width ^ 2)| kitchen_length = 15 | → | 15 |
| kitchen_width = 12 | → | 12 |
| kitchen_sqft = kitchen_length * kitchen_width | → | 180 |
| diagonal = sqrt(kitchen_length ^ 2 + kitchen_width ^ 2) | → | 19.209373 |
The kitchen is 180 sqft with a 19.2-foot diagonal. The ^ operator handles exponentiation, and sqrt returns the square root.
CalcMark features: sqrt() function; exponentiation (^); derived calculations.
Circular Patio with PI
#
The backyard patio is a 12-foot diameter circle. CalcMark has PI as a built-in constant:
patio_radius = 6
patio_area = PI * patio_radius ^ 2| patio_radius = 6 | → | 6 |
| patio_area = PI * patio_radius ^ 2 | → | 113.097336 |
The area is approximately 113.1 square feet. PI is read-only — you can’t reassign it. E (Euler’s number) is also available.
CalcMark features: PI constant; exponentiation with constants.
Precise Display #
Concrete is sold per square foot, so you need the exact area for your order. The as precise modifier shows full precision, skipping CalcMark’s default display rounding:
patio_area as precise| patio_area as precise | → | 113.097336 |
This shows 113.097336 instead of a rounded value. Useful when you need exact quantities for materials ordering. It’s the opposite of as napkin.
CalcMark features: as precise modifier.
Material Costs #
Cabinets, countertops, patio concrete, and tile flooring. Multiplying a number by a currency preserves the $ unit:
cabinets = $6200
countertop_sqft = 45
countertop_rate = $75
countertops = countertop_sqft * countertop_rate
Patio concrete at $8/sqft (rounded up to nearest whole number):
patio_concrete = patio_area * $8
Tile flooring for the kitchen:
tile_per_sqft = $12
flooring = kitchen_sqft * tile_per_sqft| cabinets = $6200 | → | $6,200.00 |
| countertop_sqft = 45 | → | 45 |
| countertop_rate = $75 | → | $75.00 |
| countertops = countertop_sqft * countertop_rate | → | $3,375.00 |
| patio_concrete = patio_area * $8 | → | $904.78 |
| tile_per_sqft = $12 | → | $12.00 |
| flooring = kitchen_sqft * tile_per_sqft | → | $2,160.00 |
Countertops come to $3,375, patio concrete $904.78, and kitchen flooring $2,160. CalcMark preserves currency types through arithmetic — the result of 45 * $75 is $3,375, not a plain number.
CalcMark features: Currency literals ($); currency arithmetic; markdown prose between calculations.
Rate Conversion with convert_rate
#
Your contractor charges $800/day. The convert_rate function converts a rate to a different time unit without accumulating:
daily_rate = $800/day
weekly_rate = convert_rate(daily_rate, week)| daily_rate = $800/day | → | 800 $/day |
| weekly_rate = convert_rate(daily_rate, week) | → | 5.6K $/week |
The weekly rate is $5,600/week. This is different from $800/day over 1 week, which would accumulate the rate into a total ($5,600 flat). convert_rate keeps it as a rate.
CalcMark features: convert_rate() function; rate literals ($800/day).
Accumulation with accumulate
#
Lumber arrives at 2 pallets per day over the 3-week build. The accumulate function totals a rate over a duration:
total_deliveries = 2 pallets/day over 3 weeks| total_deliveries = 2 pallets/day over 3 weeks | → | 42 pallets |
That’s 42 pallets total. CalcMark handles the unit conversion (days to weeks) automatically. The over keyword is the natural language form — you can also write accumulate(2 pallets/day, 3 weeks) using function-call syntax.
CalcMark features: rate accumulation with over; rate with custom units (pallets/day); automatic time unit conversion.
Project Budget #
The X% of value syntax calculates a percentage directly:
subtotal = cabinets + countertops + patio_concrete + flooring
contingency = 15% of subtotal
total = subtotal + contingency| subtotal = cabinets + countertops + patio_concrete + flooring | → | $12.64K |
| contingency = 15% of subtotal | → | $1,895.97 |
| total = subtotal + contingency | → | $14.54K |
Subtotal is $12,640, plus a 15% contingency of $1,896, for a total of $14,536.
CalcMark features: X% of value syntax; currency addition across sections.
Boolean Logic #
CalcMark supports and, or, and not operators that produce boolean results. Here you check two conditions at once:
budget_ok = total < $50000 and contingency > $1500
under_budget = not (total > $50000)| budget_ok = total < $50000 and contingency > $1500 | → | true |
| under_budget = not (total > $50000) | → | true |
Both evaluate to true. The and operator requires both comparisons to be true. The not operator inverts a boolean. You can also use or to check if either condition is true.
CalcMark features: Boolean operators (and, not); comparison operators (<, >); parentheses for grouping.
Napkin Math #
The as napkin modifier rounds to 2 significant figures with a human-readable suffix:
total as napkin| total as napkin | → | $15K |
The total rounds from $14,536 to ~$15K — a quick number for conversation.
CalcMark features: as napkin modifier.
Features Demonstrated #
This example showcases the following CalcMark features:
avg()— averaging multiple valuessqrt()— square root for geometric calculationsPIconstant — built-in mathematical constantas precise— full-precision display for exact valuesconvert_rate()— converting rates to different time unitsaccumulate()— totaling a rate over a durationX% of value— percentage calculations- Boolean operators —
and,notwith comparison operators as napkin— quick rounding for estimates- Currency arithmetic —
$preserved through calculations - Rate literals —
$800/day,2 pallets/day - Custom units —
palletsas a custom unit
Try It #
testdata/examples/home-renovation.cmcm testdata/examples/home-renovation.cm