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 a decimal addons/electrical/main.js:299 in activate CadCraft
    const u = yes(await c.keyword(t('ask.symlib.units'), { options: [opt('M', t('opt.mm')), opt('I', t('opt.inches'))], default: per === 25.4 || per === 304.8 ? 'I' : 'M' }));

    === in per === 25.4. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:299 in activate CadCraft
    const u = yes(await c.keyword(t('ask.symlib.units'), { options: [opt('M', t('opt.mm')), opt('I', t('opt.inches'))], default: per === 25.4 || per === 304.8 ? 'I' : 'M' }));

    === in per === 304.8. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:301 in activate CadCraft
    const scale = u === 'I' ? 25.4 : per >= 10 && per !== 25.4 && per !== 304.8 ? per : 1;

    !== in per !== 25.4. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:301 in activate CadCraft
    const scale = u === 'I' ? 25.4 : per >= 10 && per !== 25.4 && per !== 304.8 ? per : 1;

    !== in per !== 304.8. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal m3d/tools.js:1542 in computeGrips CadCraft
    if (f.every((x) => x === 0.5)) continue;

    === in x === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: 3D drawing and editing tools.

  • Against a decimal m3d/tools.js:1543 in computeGrips CadCraft
    const mask = f.map((x, a) => x !== 0.5 && live[a]);

    !== in x !== 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: 3D drawing and editing tools.

  • Against a decimal process/env/cheminfo.js:77 in parse CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { sum[b.a] += b.order === 1.5 ? 1 : b.order; sum[b.b] += b.order === 1.5 ? 1 : b.order; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:77 in parse CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { sum[b.a] += b.order === 1.5 ? 1 : b.order; sum[b.b] += b.order === 1.5 ? 1 : b.order; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:126 in toMol CadCraft, BimCraft
    mol.bonds.forEach((b) => L.push(pad(b.a + 1, 3) + pad(b.b + 1, 3) + pad(b.order === 1.5 ? 4 : b.order, 3) + '  0'));

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:136 in fromMol CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { const o = b.order === 1.5 ? 1 : b.order; sum[b.a] += o; sum[b.b] += o; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:148 in toSvg CadCraft, BimCraft
    out += b.order === 2 || b.order === 1.5 ? ln(nx, ny) + ln(-nx, -ny) : b.order === 3 ? ln(0, 0) + ln(2 * nx, 2 * ny) + ln(-2 * nx, -2 * ny) : ln(0, 0);

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:179 in groupsOf CadCraft, BimCraft
    const dbl = nb[i].filter((x) => x.order === 2).length, trp = nb[i].filter((x) => x.order === 3).length, arom = nb[i].some((x) => x.order === 1.5);

    === in x.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/dispersion.js:100 in screen CadCraft, BimCraft
    const notes = ['Stability-class screening on flat ground, one source, no buildings. Ta ' + Ta + ' K' + (Ta === 293.15 ? ' (assumed: give the real ambient temperature)' : '') + '.',

    === in Ta === 293.15. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Stack plume rise and air dispersion screening.

  • Against a decimal process/env/molsketch.js:106 in fromMolecule CadCraft, BimCraft
    for (const b of mol.bonds) s.bonds.push({ a: b.a, b: b.b, order: b.order === 1.5 ? 1 : b.order });

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal process/env/molsketch.js:114 in kekulise CadCraft, BimCraft
    const arom = mol.bonds.map((b, k) => ({ k, a: b.a, b: b.b })).filter((e) => mol.bonds[e.k].order === 1.5 && need[e.a] && need[e.b]);

    === in mol.bonds[e.k].order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal process/equip/vessel.js:113 in flatHead CadCraft, BimCraft
    return { t, tMin: t + ca, C, notes: C === 0.33 ? ['C = 0.33 is the plain-plate value; the attachment detail of Figure UG-34 sets the real C (0.17 to 0.33 and others): give it'] : [], source: 'ASME VII

    === in C === 0.33. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Pressure vessel thickness and support formulas.

  • Against a decimal usd/util.js:60 in floatToHalf CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    return sign | (rest > 0.5 || (rest === 0.5 && (r & 1)) ? r + 1 : r);

    === in rest === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Half floats in USD.

  • Against a decimal io/pbr.js:49 in gltfToOpenPBR ModelCraft
    if (m.ior !== 1.5) p.specular_ior = m.ior;

    !== in m.ior !== 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Imported material parameters.

  • Against a decimal io/pbr.js:107 in openPBRToGltf ModelCraft
    if (p.specular_ior !== undefined && p.specular_ior !== 1.5) ext('KHR_materials_ior', { ior: round(p.specular_ior) });

    !== in p.specular_ior !== 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Imported material parameters.

  • Against a decimal tools.js:1542 in computeGrips ModelCraft
    if (f.every((x) => x === 0.5)) continue;

    === in x === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal tools.js:1543 in computeGrips ModelCraft
    const mask = f.map((x, a) => x !== 0.5 && live[a]);

    !== in x !== 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal cs-tensor.js:60 in pow PartCraft
    if (y === 0.5) return Math.sqrt(x);

    === in y === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: CraftScript array arithmetic.

  • Against a decimal field/lattice.js:23 PartCraft
    for (let i = 0; i < 6; i++) for (let j = i + 1; j < 6; j++) { const d2 = (faces[i][0] - faces[j][0]) ** 2 + (faces[i][1] - faces[j][1]) ** 2 + (faces[i][2] - faces[j][2]) ** 2; if (d2 === 0.5) out.pus

    === in d2 === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Voxel grid and lattice struts.

  • Against a decimal assets/js/engines/plc/std.js:78 in roundEven Shared shell, every app
    const roundEven = (x) => { const r = Math.round(x); return Math.abs(x % 1) === 0.5 && r % 2 !== 0 ? r - 1 : r; };

    === in Math.abs(x % 1) === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Controller standard functions and integer types.

  • Against a decimal assets/js/engines/risk/weibull.js:55 in fitMLE Shared shell, every app
    const z = level === 0.95 ? 1.96 : level === 0.99 ? 2.576 : 1.645;

    === in level === 0.95. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Weibull life data.

  • Against a decimal assets/js/engines/risk/weibull.js:55 in fitMLE Shared shell, every app
    const z = level === 0.95 ? 1.96 : level === 0.99 ? 2.576 : 1.645;

    === in level === 0.99. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Weibull life data.

  • Two computed values bimcraft.js:4827 in update BimCraft
    for (const p of editor.placer().placements().filter((x) => x.uuid === r.uuid && Number(x.version) === Number(r.version))) {

    === in Number(x.version) === Number(r.version). Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Measurements and typed values in the main window.

  • Two computed values compute/parity.js:75 in compareImages BimCraft, ModelCraft
    if (ref.w !== test.w || ref.h !== test.h) throw new Error('parity: pictures of different sizes');

    !== in ref.w !== test.w. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Statistical comparison of rendered pictures.

  • Two computed values compute/parity.js:75 in compareImages BimCraft, ModelCraft
    if (ref.w !== test.w || ref.h !== test.h) throw new Error('parity: pictures of different sizes');

    !== in ref.h !== test.h. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Statistical comparison of rendered pictures.

  • Two computed values exr/exr.js:646 in get BimCraft, ModelCraft
    if (c.width === width && c.height === height) return (i) => c.data[i];

    === in c.width === width. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: OpenEXR and Radiance HDR picture files.

  • Two computed values exr/exr.js:646 in get BimCraft, ModelCraft
    if (c.width === width && c.height === height) return (i) => c.data[i];

    === in c.height === height. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: OpenEXR and Radiance HDR picture files.

  • Two computed values ifc/geo-tri.js:55 in ring BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (last && first !== last && last.x === first.x && last.y === first.y) remove(last), (last = last.prev);

    === in last.x === first.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:55 in ring BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (last && first !== last && last.x === first.x && last.y === first.y) remove(last), (last = last.prev);

    === in last.y === first.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:62 in rightmost BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    function rightmost(n) { let r = n, p = n; do { if (p.x > r.x || (p.x === r.x && p.y < r.y)) r = p; p = p.next; } while (p !== n); return r; }

    === in p.x === r.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:77 in bridgeHole BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (a.y !== b.y) {

    !== in a.y !== b.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:92 in bridgeHole BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (inside && !(p.x === m.x && p.y === m.y)) {

    === in p.x === m.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:92 in bridgeHole BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (inside && !(p.x === m.x && p.y === m.y)) {

    === in p.y === m.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.x !== a.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.y !== a.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.x !== c.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.y !== c.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.x !== b.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:118 in isEar BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if (p.i !== a.i && p.i !== b.i && p.i !== c.i && (p.x !== a.x || p.y !== a.y) && (p.x !== c.x || p.y !== c.y) && (p.x !== b.x || p.y !== b.y) && inTri(a, b, c, p) && cross(p.prev, p, p.next) <= 0) ret

    !== in p.y !== b.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:153 in between BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if ((a.x === b.x && a.y === b.y) || (c.x === b.x && c.y === b.y)) return false;

    === in a.x === b.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:153 in between BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if ((a.x === b.x && a.y === b.y) || (c.x === b.x && c.y === b.y)) return false;

    === in a.y === b.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:153 in between BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if ((a.x === b.x && a.y === b.y) || (c.x === b.x && c.y === b.y)) return false;

    === in c.x === b.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values ifc/geo-tri.js:153 in between BimCraft, TakeoffCraft, CivilCraft, DetailCraft
    if ((a.x === b.x && a.y === b.y) || (c.x === b.x && c.y === b.y)) return false;

    === in c.y === b.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation by ear clipping.

  • Two computed values live.js:86 in end BimCraft
    if (was && now && was.t === now.t && JSON.stringify(enc(was.p)) === JSON.stringify(enc(now.p))) continue;

    === in was.t === now.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Not in the register.

  • Two computed values raster.js:171 in openAsc BimCraft, CivilCraft
    gt: [h.xll, h.dx, 0, h.yll + h.nrows * h.dy, 0, -h.dy], pixelIsPoint: false, cell: h.dx === h.dy ? h.dx : null,

    === in h.dx === h.dy. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Elevation grids read from GeoTIFF and ASCII files.

  • Two computed values render/anim.js:129 in sortKeys BimCraft, ModelCraft
    for (const k of keys) { if (out.length && out[out.length - 1].t === k.t) out[out.length - 1] = k; else out.push(k); }

    === in out[out.length - 1].t === k.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Animation keys, curves and poses.