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.