Resources Numerical accuracy

Equality comparisons

Where the code asks whether two decimal numbers are exactly equal. A floating-point result can differ from another in the last digit after a few transformations, so a mesh run through several of them can change the length of an edge, or miss a match. Compare with < or > where a range is meant, and with a documented epsilon where equality is.

  • 316 comparisons to look at
  • 149 files
  • 175 likely to matter (against a decimal, or two computed values)
  • Scanned

Equality comparisons

These are places worth checking, not confirmed bugs. The scan reads how the code is written, not what it is meant to do, so some entries are fine as they are: a test against exactly 0 is often a deliberate guard against dividing by zero. It skips text, counts and indexes, and any comparison it cannot be sure involves decimal numbers, so there are likely more in the code than are listed here.

  • Against 1 clip.js:49 in readClip CivilCraft
    if (!obj || typeof obj !== 'object' || obj.format !== CLIP_FORMAT || obj.v !== 1 || !Array.isArray(obj.pts)) return null;

    !== in obj.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sy === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sz === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:660 in insertScale DetailCraft, PartCraft
    else if (sx === 1) { w.BB(1); w.DD(sy, 1); w.DD(sz, 1); }

    === in sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:774 DetailCraft, PartCraft
    const weights = ctrl.some((p) => p.w !== undefined && p.w !== 1) || (r.weights || []).some((x) => x !== 1);

    !== in p.w !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:818 DetailCraft, PartCraft
    const rational = ctl.some((p) => p.w !== undefined && p.w !== 1);

    !== in p.w !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 lib-supply/supply.js:115 in readSupply DetailCraft
    if (!json || typeof json !== 'object' || json.v !== 1) return null;

    !== in json.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Supplier stock and lead-time check.

  • Against 1 base-ui.js:580 in scaleFor MarkupCraft
    if (keep) { const s = Math.max(Math.abs(sx === 1 && !grip.key.match(/[ew]/) ? sy : sx), Math.abs(sy === 1 && !grip.key.match(/[ns]/) ? sx : sy)); sx = Math.sign(sx) * s; sy = Math.sign(sy) * s; }

    === in sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 base-ui.js:580 in scaleFor MarkupCraft
    if (keep) { const s = Math.max(Math.abs(sx === 1 && !grip.key.match(/[ew]/) ? sy : sx), Math.abs(sy === 1 && !grip.key.match(/[ns]/) ? sx : sy)); sx = Math.sign(sx) * s; sy = Math.sign(sy) * s; }

    === in sy === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 clip.js:82 in cleanClip MarkupCraft
    if (!d || typeof d !== 'object' || d.format !== CLIP_FORMAT || d.v !== 1 || !Array.isArray(d.items)) return null;

    !== in d.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Area markup with cut-outs, and clipboard placement.

  • Against 1 content-clip.js:86 in cleanContentClip MarkupCraft
    if (!d || typeof d !== 'object' || d.format !== CONTENT_FORMAT || d.v !== 1) return null;

    !== in d.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Carried, stamped and pasted markup geometry.

  • Against 1 markupcraft.js:4498 in recover MarkupCraft
    if (!rec.data?.pdf || !st || st.v !== 1) throw new Error(t('recover.bad'));

    !== in st.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Sheet scale, typed lengths and measured values, Markup geometry while drawing and editing, Drawing comparison by vector paths.

  • Against 1 pdf-read.js:146 in fromPrivate MarkupCraft
    if (!d || typeof d !== 'object' || d.v !== 1 || typeof d.type !== 'string' || !TYPES[d.type] || d.type === 'foreign') return null;

    !== in d.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Annotations and scales read from a PDF.

  • Against 1 records.js:156 in unpackRecords MarkupCraft
    if (!v || typeof v !== 'object' || v.v !== 1 || !Array.isArray(v.records)) return [];

    !== in v.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 mesh/ops.js:773 in splitByPoints ModelCraft
    if (inSplit.has(f) && on.length === 2 && Math.abs(on[0] - on[1]) !== 1 && Math.abs(on[0] - on[1]) !== vs.length - 1) {

    !== in Math.abs(on[0] - on[1]) !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Proportional editing weights and edge creases, Inset, bevel and moves along normals, Subdivide, loop cut, bisect, knife and grid fill, Merge, spin, bridge, slide and smooth.

  • Against 1 model-info.js:58 in cleanTemplate ModelCraft
    if (!v || typeof v !== 'object' || v.v !== 1) return null;

    !== in v.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 nurbs/step.js:302 in trimOf ModelCraft, PartCraft
    let seg = c.deg === 1 ? c.cvs.slice() : Array.from({ length: 33 }, (_, i) => C.point(c, a + (z - a) * i / 32));

    === in c.deg === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: STEP files of NURBS curves and surfaces.

  • Against 1 skp/messages.js:160 in msg ModelCraft
    if (typeof s === 'object') s = s['=' + fills.n] ?? (Number(fills.n) === 1 ? s.one : s.other) ?? s.other;

    === in Number(fills.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sy === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sz === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 flow-study.js:82 in readFlow PartCraft
    if (typeof raw !== 'object' || Array.isArray(raw) || raw.v !== 1) bad(t('study.flow.err.bad_study'));

    !== in raw.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Flow study: fluid cells, openings and wall distances, Flow study: 32-bit steps in the mesh and the result fields.

  • Against 1 sim.js:80 in readSimStudy PartCraft
    if (!raw || typeof raw !== 'object' || Array.isArray(raw) || raw.v !== 1) bad(t('study.sim.err.bad_study'));

    !== in raw.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Study set-up: element size and the mesh handed to the solver.

  • Against 1 sim.js:97 in readGenStudy PartCraft
    if (!raw || typeof raw !== 'object' || Array.isArray(raw) || raw.v !== 1) bad(t('study.sim.err.bad_gen'));

    !== in raw.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Study set-up: element size and the mesh handed to the solver.

  • Against 1 swmacro.js:1569 in partToSwb PartCraft
    if (info.factor !== 1) rhs = `(${rhs}) * ${formatNumber(info.factor)}`;

    !== in info.factor !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Numbers written into the VBA macro export.

  • Against 1 assets/js/addon-license.js:50 in verifyEntitlement Shared shell, every app
    if (!payload || payload.v !== 1 || !Number.isFinite(payload.exp)) return { ok: false, reason: 'bad-signature' };

    !== in payload.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 assets/js/calc.js:240 in dimText Shared shell, every app
    d.forEach((x, i) => { if (Math.abs(x) < 1e-9) return; const s = BASE_NAMES[i] + (Math.abs(x) === 1 ? '' : '^' + sig(Math.abs(x), 3)); (x > 0 ? top : bot).push(s); });

    === in Math.abs(x) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Calc sheets, Calc sheet units, functions and driven parameters.

  • Against 1 assets/js/live-crypto.js:329 in verifyAssertion Shared shell, every app
    if (!sig || !claims || claims.v !== 1 || typeof claims.name !== 'string') return { ok: false, reason: 'format' };

    !== in claims.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 carbon.js:32 in readCarbon TakeoffCraft
    if (!json || typeof json !== 'object' || json.v !== 1) return null;

    !== in json.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Embodied carbon from quantities, Rates exported as a price table.

  • Against 1 prices.js:31 in readStore TakeoffCraft
    if (!json || typeof json !== 'object' || json.v !== 1) return s;

    !== in json.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 supply.js:99 in readSupply TakeoffCraft
    if (!json || typeof json !== 'object' || json.v !== 1) return null;

    !== in json.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Supplier stock and lead-time check.