Resources Numerical accuracy Calculation policy

Massing window read-outs and typed height

The footprint and floor-area read-outs of a building mass, the zoning coverage field, and what happens to a typed height.

How the precision is kept

Areas and volumes come from massing.js as 64-bit numbers and are formatted here. A typed building height is not stored: it is divided by the floor height and rounded to a whole number of floors.

Calculations under this policy

3 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

massing-ui.js CivilCraft 0.8.1 64-bit 3 calculations Reviewed

Tests None found by the review

Area read-out

64-bit

Prints an area in the project's area unit.

text = round to 0 decimals, grouped

The area is rounded to a whole unit only in the text; the stored mass is not changed.

  • massing-ui.js
  • line 37
  • CivilCraft 0.8.1
const area = (v) => grouped(v, 0) + ' ' + unitOf(U()).area;

Typed height to floors

64-bit

Turns a height the person types into a whole number of floors.

floors = clamp(round(H ÷ floor height), 1, max floors)

The division is 64-bit and Math.round snaps it to a whole floor, so the typed height itself is not kept. The same rounding is in massing.js setHeight.

  • massing-ui.js
  • line 171
  • CivilCraft 0.8.1
const hgt = ctx.numInput(fixed(massHeight(m), 2).replace(/,/g, ''), (v) => { const n = Number(v); if (!(n > 0)) return false; edit(m.id, t('ms.undo.height'), (q) => { q.floors = setHeight(q, n); }); return true; }, { label: t('ms.height', { u: L() }), id: 'cv-ms-height', width: '6rem' });

Zoning coverage percent

64-bit

Turns the percent a person types for building coverage into the stored fraction.

coverage = n ÷ 100

The typed text is converted with Number and divided by 100 in 64-bit arithmetic. The field shows the stored value back as coverage × 100 with 1 decimal.

  • massing-ui.js
  • line 82
  • CivilCraft 0.8.1
...ctx.row(t('zn.coverage'), ctx.numInput(z.coverage ? fixed(z.coverage * 100, 1).replace(/,/g, '') : '', (v) => { const s = String(v).trim(), n = s === '' ? 0 : Number(s); if (!(n >= 0 && n <= 100)) return false; editZone(parcelId, t('zn.undo.set'), (q) => { q.coverage = n / 100; }); return true; }, { label: t('zn.coverage'), id: 'cv-zn-cov', width: '6rem', calc: false }), 'cv-zn-cov'),

In detail

Method
Areas are printed with thousands separators and no decimals; typed height becomes floors = round(height ÷ floor height), limited to 1 to the maximum floors.
Number types
64-bit numbers; no 32-bit array is read in this file.
Tolerances
None.
Limits
After a typed height is entered the height shown is floors × floor height, which differs from the typed value by up to half a floor.

Approach: 64-bit, stated limit

The arithmetic is 64-bit, but the method or the data sets the accuracy: a solver tolerance, a mesh, a step size, a datum shift, a table. The limit is stated where the result is shown.

Every policy that takes this approach