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 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.

  • 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 dwg/objects-write.js:659 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sy. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: DWG object values written and read.

  • Two computed values dwg/objects-write.js:659 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sz. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: DWG object values written and read.

  • Two computed values m3d/earcut.js:161 in findHoleBridge CadCraft, TakeoffCraft
    if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {

    !== in p.next.y !== p.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:179 in findHoleBridge CadCraft, TakeoffCraft
    if (locallyInside(p, hole) && (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {

    === 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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:194 in getLeftmost CadCraft, TakeoffCraft
    if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;

    === in p.x === leftmost.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:217 in equals CadCraft, TakeoffCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

    === in p1.x === p2.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:217 in equals CadCraft, TakeoffCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

    === in p1.y === p2.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:247 in middleInside CadCraft, TakeoffCraft
    if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) inside = !inside;

    !== in p.next.y !== p.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Triangulation of faces with holes.

  • Two computed values unit-table.js:126 in convert CadCraft, BimCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (a === b || a.factor === b.factor) return v;

    === in a.factor === b.factor. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Unit conversion, Unit table: reading and writing values.

  • Two computed values usd/earcut.js:162 in findHoleBridge CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {

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

  • Two computed values usd/earcut.js:180 in findHoleBridge CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (locallyInside(p, hole) && (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {

    === 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 (ear clipping).

  • Two computed values usd/earcut.js:195 in getLeftmost CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;

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

  • Two computed values usd/earcut.js:218 in equals CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

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

  • Two computed values usd/earcut.js:218 in equals CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

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

  • Two computed values usd/earcut.js:248 in middleInside CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) inside = !inside;

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

  • Two computed values usd/geom.js:92 in valueAt CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (!a || !b || a.t !== b.t || typeof a.v === 'string' || a.t.startsWith('quat') || a.t.includes('token') || a.t === 'bool') return a;

    !== in a.t !== b.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: USD transforms and placement, USD mesh coordinates in saved and exported files.

  • Two computed values fixedqty.js:76 in importQuantities TakeoffCraft
    if (old.qty === q.qty && old.unit === q.unit) { out.same++; continue; }

    === in old.qty === q.qty. 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 model.js:641 in setMarksArea TakeoffCraft
    if (!set.has(m.id) || (m.area || null) === (area || null)) continue;

    === in (m.area || null) === (area || null). Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Takeoff quantities from marks, Priced estimate.

  • Two computed values model.js:934 in quantities TakeoffCraft
    if (area !== undefined && (m.area || null) !== area) continue;      // one bid area (null: the marks in none)

    !== in (m.area || null) !== area. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Takeoff quantities from marks, Priced estimate.

  • Against 1 dwg/messages.js:188 in msg CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    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 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:660 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:774 CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:818 CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DWG object values written and read.

  • Against 1 dxf-model.js:58 in msg CadCraft, BimCraft, TakeoffCraft, CivilCraft
    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. Reviewed: DXF reading into the shared drawing model.

  • Against 1 live-crypto.js:329 in verifyAssertion CadCraft, BimCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    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 usd/usda-write.js:40 in subLayersText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    return asset(a) + (o && (o.offset !== 0 || o.scale !== 1) ? ' (' + layerOffsetText(o) + ')' : '');

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • Against 1 usd/usda-write.js:47 in layerOffsetText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (o.scale !== 1) parts.push('scale = ' + num(o.scale, 'f64'));

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • Against 1 usd/usda-write.js:172 in listItemText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (o && (o.offset !== 0 || o.scale !== 1)) parts.push(layerOffsetText(o));

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • 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.