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.
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 dxf.js:659 in entityFrom CadCraft
const sz = num(g, 43, 1); if (sz && sz !== 1) add.sz = sz;!== 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: DXF reading: objects from the file's text, DXF writing: numbers as text. -
Against 1 dxf.js:1507 in entity CadCraft
if ((e.sx ?? 1) !== 1) w(41, f(e.sx)); if ((e.sy ?? 1) !== 1) w(42, f(e.sy)); if (Number.isFinite(e.sz) && e.sz && e.sz !== 1) w(43, f(e.sz)); if (e.rot) w(50, f(deg(e.rot)));!== in
(e.sx ?? 1) !== 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: objects from the file's text, DXF writing: numbers as text. -
Against 1 dxf.js:1507 in entity CadCraft
if ((e.sx ?? 1) !== 1) w(41, f(e.sx)); if ((e.sy ?? 1) !== 1) w(42, f(e.sy)); if (Number.isFinite(e.sz) && e.sz && e.sz !== 1) w(43, f(e.sz)); if (e.rot) w(50, f(deg(e.rot)));!== in
(e.sy ?? 1) !== 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: objects from the file's text, DXF writing: numbers as text. -
Against 1 libitem.js:233 in msg CadCraft, BimCraft
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: Library item geometry from blocks, meshes and tables, Lengths and units for Library items. -
Against 1 libitem.js:1465 in drawingUnits CadCraft, BimCraft
const metric = Number(db.header?.MEASUREMENT) === 1;=== in
Number(db.header?.MEASUREMENT) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Library item geometry from blocks, meshes and tables, Lengths and units for Library items. -
Against 1 libpanel.js:194 in search CadCraft
sayAfterEnd(r.total ? r.total + ' item' + (r.total === 1 ? '' : 's') + (r.total > cards.length ? ', showing ' + cards.length : '') + '.' : t('lib.panel.nothing_found'));=== in
r.total === 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 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 process/env/cheminfo.js:182 in groupsOf CadCraft, BimCraft
if (arom) inc(a.h === 1 ? 'ring =CH-' : a.h === 0 ? 'ring =C<' : 'ring =CH-');=== in
a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates. -
Against 1 process/env/cheminfo.js:184 in groupsOf CadCraft, BimCraft
else if (dbl) { if (nb[i].some((x) => x.order === 2 && mol.atoms[x.o].el !== 'C')) missing.push('carbonyl or C=X carbon'); else if (inRing[i]) missing.push('ring alkene carbon'); else if (dbl === 1 &&=== in
a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates. -
Against 1 process/env/cheminfo.js:185 in groupsOf CadCraft, BimCraft
else if (inRing[i]) { if (a.h === 2) inc('ring CH2'); else if (a.h === 1) inc('ring CH'); else missing.push('ring quaternary carbon'); }=== in
a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates. -
Against 1 process/env/cheminfo.js:188 in groupsOf CadCraft, BimCraft
if (a.h === 1 && nb[i].length === 1 && !mol.atoms[nb[i][0].o].aromatic) inc('-OH (alcohol)');=== in
a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates. -
Against 1 process/env/molsketch.js:85 in symbol CadCraft, BimCraft
return '[' + el + (a.h ? (a.h === 1 ? 'H' : 'H' + a.h) : '') + (q ? (q > 0 ? '+' + (q > 1 ? q : '') : '-' + (q < -1 ? -q : '')) : '') + ']';=== in
a.h === 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 process/live.js:37 in readPacket CadCraft, BimCraft
if (!raw || typeof raw !== 'object' || raw.format !== FORMAT || raw.v !== 1) return null;!== 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. Not in the register. -
Against 1 process/safety/hazoptimer.js:57 in restore CadCraft, BimCraft
if (!s || s.v !== 1 || !Array.isArray(s.rows)) return false;!== in
s.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 redline.js:46 in readRedline CadCraft
if (o.v !== 1) return { ok: false, pkg: null, errors: ['version'] };!== in
o.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Redline items placed in the drawing. -
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 0 addons/trusscraft/lib/design.js:130 in designTruss CadCraft, BimCraft, ModelCraft, PartCraft
const closed = g.profile ? g.nodes.find((n) => n.x === 0 && n.z === 0) : true;=== in
n.x === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Truss member forces and timber checks. -
Against 0 addons/trusscraft/lib/design.js:130 in designTruss CadCraft, BimCraft, ModelCraft, PartCraft
const closed = g.profile ? g.nodes.find((n) => n.x === 0 && n.z === 0) : true;=== in
n.z === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Truss member forces and timber checks. -
Against 0 lencalc.js:130 in term CadCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft
if (o.t === '/' && b.v === 0) throw new CalcError('divide', o.pos);=== in
b.v === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Arithmetic on typed lengths. -
Against 0 lisp/dxflist.js:152 in fromPairs CadCraft
else if (has(62)) { const c = get(pairs, 62); e.color = c === 256 ? null : Math.abs(c) === 0 ? 0 : Math.min(255, Math.abs(c)); }=== in
Math.abs(c) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Drawing values handed to and from LISP routines. -
Against 0 m3d/earcut.js:51 in filterPoints CadCraft, TakeoffCraft
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {=== in
area(p.prev, p, p.next) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Triangulation of faces with holes. -
Against 0 m3d/lencalc.js:130 in term CadCraft
if (o.t === '/' && b.v === 0) throw new CalcError('divide', o.pos);=== in
b.v === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register. -
Against 0 m3d/tools.js:727 in value CadCraft
if (!Number.isFinite(deg) || deg === 0) return false;=== in
deg === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: 3D drawing and editing tools. -
Against 0 m3d/tools.js:1138 in pickPoint CadCraft
this.k = 1 / Math.max(len(this.T.localDir(this.n)), 1e-9) === 0 ? 1 : len(this.T.localDir(this.n));=== in
1 / Math.max(len(this.T.localDir(this.n)), 1e-9) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: 3D drawing and editing tools. -
Against 0 pointcloud.js:721 in scanPtx CadCraft, BimCraft
if (px === 0 && py === 0 && pz === 0) { missing++; return; }=== in
px === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Point cloud positions and read-in values. -
Against 0 pointcloud.js:721 in scanPtx CadCraft, BimCraft
if (px === 0 && py === 0 && pz === 0) { missing++; return; }=== in
py === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Point cloud positions and read-in values. -
Against 0 pointcloud.js:721 in scanPtx CadCraft, BimCraft
if (px === 0 && py === 0 && pz === 0) { missing++; return; }=== in
pz === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Point cloud positions and read-in values. -
Against 0 process/env/cheminfo.js:182 in groupsOf CadCraft, BimCraft
if (arom) inc(a.h === 1 ? 'ring =CH-' : a.h === 0 ? 'ring =C<' : 'ring =CH-');=== in
a.h === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Molar mass and group-contribution estimates. -
Against 0 process/env/cheminfo.js:189 in groupsOf CadCraft, BimCraft
else if (a.h === 0 && nb[i].length === 2 && !inRing[i] && nb[i].every((x) => x.order === 1 && !mol.atoms[x.o].aromatic)) inc('-O- (non-ring)');=== in
a.h === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Molar mass and group-contribution estimates. -
Against 0 process/equip/pipestress.js:109 in buildModel CadCraft, BimCraft
const W = { id: 'W', name: 'Weight', kind: 'dead', selfWeight: 1, loads: fm.members.map((e) => ({ type: 'udl', member: e.id, dir: 'Z', w: -(wContents + wIns) })).filter((l) => l.w !== 0) };!== in
l.w !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Pipe stress checks. -
Against 0 usd/earcut.js:52 in filterPoints CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {=== in
area(p.prev, p, p.next) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Polygon triangulation (ear clipping). -
Against 0 usd/usda-read.js:476 in component CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
if (c.k === 'num') { this.i++; return c.v !== 0; }!== in
c.v !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Floats read from USD files. -
Against 0 wheel-pad.js:20 in isSwipe CadCraft, BimCraft, MarkupCraft, TakeoffCraft, CivilCraft
const step = dx === 0 && ((Number.isFinite(e.wheelDeltaY) && e.wheelDeltaY !== 0 && e.wheelDeltaY % 120 === 0) || (Number.isInteger(dy) && Math.abs(dy) >= 50));=== in
dx === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register. -
Against 0 wheel-pad.js:22 in isSwipe CadCraft, BimCraft, MarkupCraft, TakeoffCraft, CivilCraft
if (dx !== 0 || !Number.isInteger(dy) || Math.abs(dy) < 50) { this.until = t + 400; return true; }!== in
dx !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register.